Attach to shell process of a running container:
docker exec -it <CONTAINER> bash
ctrl + p + ctrl + q detatch from container without exiting shell
ctrl + q exit while running in bash
Spin an image with another entrypoint if entrypoint in container stops before being able to attach to shell process of a running container
docker run -ti --entrypoint=bash <IMAGE>
copies files or folders between a container and the local filesystem.
docker cp <CONTAINER>:<SRC_PATH> <DEST_PATH> (copying from container to local file)
docker cp <SRC_PATH> <CONTAINER>:<DEST_PATH> (copying from local file to container)
docker images shows all images.
docker pull <IMAGE> pulls image from dockerhub
docker build <PATH> creates image from Dockerfile.
docker rmi <IMAGE> removes an image.
docker run <IMAGE> creates a container from image
flags for docker run (add flag before <IMAGE>):
-d detached container
--rm container removed when it exits
--name <NAME> names the container
docker start <CONTAINER> starts a container so it is running.
docker stop <CONTAINER> stops a running container.
docker rename <CONTAINER> <NEW_NAME>
docker restart <CONTAINER> stops and starts a container.
docker pause <CONTAINER> pauses a running container, "freezing" it in place.
docker unpause <CONTAINER> will unpause a running container.
docker kill <CONTAINER> sends a SIGKILL to a running container.
docker commit <CONTAINER> creates image from a container, pausing it temporarily if it is running.
list all running docker containers:
docker ps
docker ps -a (includes stopped containers)
gets logs from container:
docker logs <CONTAINER>
docker logs <CONTAINER> --follow (shows running log)
gets all container info (including IP address).:
docker inspect <CONTAINER>
gets container's open ports:
docker port <CONTAINER>
shows container's running processes:
docker top <CONTAINER>
docker rm <CONTAINER...> removes container(s)
docker rmi <IMAGE...> remove image(s)
docker system prune removes all unused containers, networks, images