cheat-fork-echo/cheat/cheatsheets/docker

33 lines
921 B
Plaintext
Raw Normal View History

2014-10-23 06:48:25 +02:00
# Start docker daemon
docker -d
# start a container with an interactive shell
docker run -ti <image_name> /bin/bash
2015-01-13 04:51:35 +01:00
# "shell" into a running container (docker-1.3+)
docker exec -ti <container_name> bash
2014-10-23 06:48:25 +02:00
# inspect a running container
docker inspect <container_name> (or <container_id>)
# Get the process ID for a container
# Source: https://github.com/jpetazzo/nsenter
docker inspect --format {{.State.Pid}} <container_name_or_ID>
# List the current mounted volumes for a container (and pretty print)
# Source:
# http://nathanleclaire.com/blog/2014/07/12/10-docker-tips-and-tricks-that-will-make-you-sing-a-whale-song-of-joy/
docker inspect --format='{{json .Volumes}}' <container_id> | python -mjson.tool
2015-11-17 13:35:03 +01:00
# Copy files/folders between a container and your host
docker cp foo.txt mycontainer:/foo.txt
2014-10-23 06:48:25 +02:00
# list currently running containers
docker ps
# list all containers
docker ps -a
# list all images
2015-11-17 13:35:03 +01:00
docker images