Docker CLI
What is the syntax for the --link flag with docker run?
--link <name or id>:alias
Which parameter would allow you to customize a docker container name?
--name $NAME
What does docker's -P flag do?
Maps network ports inside the container to the container host.
How do you delete a docker container immediately after it is stopped?
The --rm flag on docker run
How long will a docker container run?
Until the command used to start it stops.
What command would attach to a running container?
docker attach $TAG
Get help for the docker command attach?
docker attach --help
What is the command to list all docker images?
docker images
What command will generate a JSON list of container settings?
docker inspect $NAME
How do you check the STDOUT of a running daemon container?
docker logs $NAME
How can you determine which local port number has been mapped to a given docker container port number?
docker port $NAME $PORTNUM (i.e. docker port nostalgic_reward 5000). docker ps will also work in list-format.
What command is used to list all running docker containers?
docker ps
What command is used to list all docker containers?
docker ps -a
What command would pull a centos6 image from the Docker image repository?
docker pull centos:centos6
How do you delete a docker container?
docker rm $NAME
What is the command to delete a docker image?
docker rmi $NAME
How would you bind udp port 63 to localhost port 63?
docker run -d -p 127.0.0.1:63:63/udp
How would you bind ports 80 and 443 from a docker container to the docker host?
docker run -d -p 80:80 -p 443:443
How do you start a container in daemonized mode?
docker run -d centos:centos6 /bin/sh
What command would run a new docker container's terminal with centos6?
docker run -t -i centos:centos6 /bin/bash. The -t flag assigns a pseudo tty to the session and the -i flag makes the session interactive by using the standard STDIN of the container.
What command would resume an existing container and run the terminal?
docker start $TAG
How do you stop a running container?
docker stop $NAME
Get docker version information?
docker version
On Fedora, how would you list all the docker images from the file system?
ls -lah /var/lib/docker/containers/