May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

docker cmd

Basic Instructions

Download the image file

$ docker pull image_name

Activate or deactivate the container
$ docker [start|stop] container_name

Download the image file

$ docker pull image_name

Activate or deactivate the container

$ docker [start|stop] container_name
Build -> Start -> Execute command ( -ti parameter)

$ docker run -ti –name container_name image_name command
Build -> Start -> Execute command -> Delete Container ( -rm parameters)

$ docker run –rm -ti image_name command
file system and the corresponding port ( -v and -p parameter)

$ docker run -ti –rm -p 80:80 -v /your_path:/container_path -e PASSWORD=1234 image_name
Docker Clear (cleanup) instruction
Delete all container being executed

$ docker kill $(docker ps -q)

Remove dangling image file

docker rmi $(docker images -q -f dangling=true)

Remove all stopped container

docker rm $(docker ps -a -q)
Docker machine instruction

Start machine

$ docker-machine start machine_name

Specifies the machine to set the docker

$ eval “$(docker-machine env machine_name)”
Interactive instruction with container

Instruction in the container

$ docker exec -ti container_name command

Online Watch container logs

$ docker logs -ft container_name

Storage container being implemented into image files

$ docker commit -m “message” -a “author” container_name username/image_name:tag

docker compose format

docker-compose.yml following format

version: “2”
service:
container_name: “hello-world”
image: golang
command: “go run hello-world.go”
ports
– “80:8080”
volumes:
– /hello-world:/root/hello-world
redis:
image: redis

Build -> Execute container

$ docker-compose up
These are commonly used docker instruction, be sure to learn for beginners.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>