Tutorial by Examples

$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2bc9b1988080 redis "docker-entrypoint.sh" 2 weeks ago Up 2 hours 0.0.0.0:6379->6379/tcp eleph...
Docker commands which take the name of a container accept three different forms: TypeExampleFull UUID9cc69f11a0f76073e87f25cb6eaf0e079fbfbd1bc47c063bcd25ed3722a8cc4aShort UUID9cc69f11a0f7Nameberserk_wozniak Use docker ps to view these values for the containers on your system. The UUID is generat...
To stop a running container: docker stop <container> [<container>...] This will send the main process in the container a SIGTERM, followed by a SIGKILL if it doesn't stop within the grace period. The name of each container is printed as it stops. To start a container which is stoppe...
docker ps --format 'table {{.ID}}\t{{.Names}}\t{{.Status}}'
docker ps --filter name=myapp_1
To find out the IP address of your container, use: docker inspect <container id> | grep IPAddress or use docker inspect docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${CID}
docker restart <container> [<container>...] Option --time : Seconds to wait for stop before killing the container (default 10) docker restart <container> --time 10
docker rm can be used to remove a specific containers like this: docker rm <container name or id> To remove all containers you can use this expression: docker rm $(docker ps -qa) By default docker will not delete a container that is running. Any container that is running will produce a...
docker exec -it <container id> /bin/bash It is common to log in an already running container to make some quick tests or see what the application is doing. Often it denotes bad container use practices due to logs and changed files should be placed in volumes. This example allows us log in the...
Usage: docker logs [OPTIONS] CONTAINER Fetch the logs of a container -f, --follow=false Follow log output --help=false Print usage --since= Show logs since timestamp -t, --timestamps=false Show timestamps --tail=all Number o...
There are two ways to achieve that, the first and most known is the following: docker attach --sig-proxy=false <container> This one literally attaches your bash to the container bash, meaning that if you have a running script, you will see the result. To detach, just type: Ctl-P Ctl-Q Bu...
from container to host docker cp CONTAINER_NAME:PATH_IN_CONTAINER PATH_IN_HOST from host to container docker cp PATH_IN_HOST CONTAINER_NAME:PATH_IN_CONTAINER If I use jess/transmission from https://hub.docker.com/r/jess/transmission/builds/bsn7eqxrkzrhxazcuytbmzp/ , the files in the contai...
Docker volumes are not automatically removed when a container is stopped. To remove associated volumes when you stop a container: docker rm -v <container id or name> If the -v flag is not specified, the volume remains on-disk as a 'dangling volume'. To delete all dangling volumes: docker ...
It is possible to save a Docker container's filesystem contents to a tarball archive file. This is useful in a pinch for moving container filesystems to different hosts, for example if a database container has important changes and it isn't otherwise possible to replicate those changes elsewhere. Pl...

Page 1 of 1