Contents

Docker Basic

Some notes about using docker

Manipulate Container

Create and run a container from an image

1
docker run <image name>
This is a tip

docker start -a (watch for the output of the container and put it to terminal)

Create and run a container and override default command

1
docker run <image name>  <command>

List all containers

1
docker ps --all

Delete all containers

1
docker system prune

Get logs from container

1
docker logs <container id>

Stop containers

1
2
docker stop <container id>
docker kill <container id>
This is a tip
docker stop will allow the process to clean up while the docker kill will terminate the process immediately

Executing commands in running container

1
docker exec -it <container id> <command>
This is a tip
-i flag direct the stdin and stdout -t format the stdin and stdout
This is a tip
docker exec -it <container id> sh get command prompt
This is a tip

alternatively,

1
docker run -it <image id> <command>

Start the container and run the command