Docker Commands
Keyword that tells Docker to copy files from a directory to the container image
COPY
Exit a shell
CTRL + D
Docker CLI
Commands used to operate Docker (Command Line Interface)
Keyword that tells Docker what command containers created from the image should run
ENTRYPOINT
Successful entry point execution
Exited (0)
Commands that customize our image
RUN statements
Keyword that tells Docker which user to use for any Docker file commands underneath it
USER
Reference containers with ____, reference images with ____
container-id, ####
docker rm does not stop ____
containers that are running
The directory provided to the Docker build
context
View Docker Commands
docker --help
build a container
docker build FILENAME --tag container-name .
docker run
docker container create + docker container start + docker container attach
initiate new container
docker container start + id
initiate new container
docker container start + id generated from create command
start container and attach terminal to the container's output
docker container start --attach
Run additional commands in container
docker exec #### commandname
tell docker a container needs to be interactive
docker exec --interactive ####
tell docker a container's shell terminal needs to interact well with our active terminal
docker exec --tty #### shellname
view message logs from running container
docker logs + first three characters of container id
Gain Info on a Command
docker network COMMAND --help
View actively running containers
docker ps
view all containers docker knows about
docker ps --all
view all created containers
docker ps -a
remove all containers
docker ps -a q | xargs docker rm
provides all containers in shell by ID only
docker ps -aq
kill a container
docker ps; identify first four characters of container ID; docker kill ####
removes all containers in server
docker rm ####
remove running containers
docker rm -f
remove images
docker rmi ####
nuclear option to force image removal
docker rmi -f ####
short way to create a docker container
docker run command-name
stop a container gently
docker stop ####
stop container with force
docker stop -t 0 ####
docker containers are not _____ by default
interactive
creates/starts container without attaching the terminal
short way: docker run -d container-name long way: docker container create container-name, followed by docker container start container-name
what to do if docker will not let you remove an image from a container that is running
stop container with docker stop -t 0 container-id; then rerun docker rmi ####
docker images
view all images