bar
5/30/2018 - 8:10 AM

docker cli

docker cli

http://phase2.github.io/devtools/common-tasks/ssh-into-a-container/


s files in docker  docker exec -t -i mycontainer /bin/bash
'docker version' check what version of docker you have running
Starting and Stopping
docker start   starts a container so it is running.
docker stop   stops a running container.
docker restart   stops and starts a container.
docker pause    pauses a running container, "freezing" it in place.
docker unpause    will unpause a running container.
docker wait    blocks until running container stops.
docker kill    sends a SIGKILL to a running container.
docker attach    will connect to a running container.
Info
docker ps   shows running containers.  docker ps -a (all running and stopped)
docker logs gets logs from container. (You can use a custom log driver, but logs is only available for json-file and journald in 1.10).
docker inspect   looks at all the info on a container (including IP address).
docker events   gets events from container.
docker port   shows public facing port of container.
docker top   shows running processes in container.
docker stats   shows containers' resource usage statistics. docker stats --a 
docker diff   shows changed files in the container's FS.
Import / Export
docker cp copies files or folders between a container and the local filesystem.
docker export turns container filesystem into tarball archive stream to STDOUT.
Executing Commands
docker exec to execute a command in container.  
        To enter a running container, attach a new shell process to a running container called foo, use: 
    docker exec -it foo /bin/bash.
Images  Images are just templates for docker containers.
Lifecycle
docker images shows all images.
docker import creates an image from a tarball.
docker build creates image from Dockerfile.
docker commit creates image from a container, pausing it temporarily if it is running.
docker rmi removes an image.
docker load loads an image from a tar archive as STDIN, including images and tags (as of 0.7).
docker save saves an image to a tar archive stream to STDOUT with all parent layers, tags & versions (as of 0.7).
Info
docker history shows history of image.
docker tag tags an image to a name (local or registry).
Load an image from file:
docker load < my_image.tar.gz


Save an existing image:      docker save my_image:my_tag | gzip > my_image.tar.gz
Import/Export container
Import a container as an image from file:
cat my_container.tar.gz | docker import - my_image:my_tag
Export an existing container:
docker export my_container | gzip > my_container.tar.gz