Lifecycle
docker
--rm remove container automatically after it exits
-it connect the container to terminal
--name web name the container
-p 5000:80 expose port 5000 externally and map to port 80
-v $hostdir:$dockerdir create a host mapped volume inside the container
alpine:3.4 the image from which the container is instantiated
/bin/sh the command to run inside the container
If you want to poke around in an image, docker run -t -i <myimage> <myshell> to open a tty.
- docker create creates a container but does not start it.
- docker run creates and starts a container in one operation.
- docker stop stops it.
- docker start will start it again.
- docker restart restarts a container.
- docker rm deletes a container.
- docker kill sends a SIGKILL to a container.
- docker attach will connect to a running container.
- docker wait blocks until container stops.
docker
--rm remove container automatically after it exits
-it connect the container to terminal
--name web name the container
-p 5000:80 expose port 5000 externally and map to port 80
-v $hostdir:$dockerdir create a host mapped volume inside the container
alpine:3.4 the image from which the container is instantiated
/bin/sh the command to run inside the container
If you want to poke around in an image, docker run -t -i <myimage> <myshell> to open a tty.
Info
- docker ps shows running containers.
- docker inspect looks at all the info on a container (including IP address).
- docker logs gets logs from container.
- docker events gets events from container.
- docker port shows public facing port of container.
- docker top shows running processes in container.
- docker diff shows changed files in the container's FS.
- docker ps -a shows running and stopped containers.
Images
- docker images shows all images.
- docker image manage images - e.g. ls / prune / rm / save / tag ....
- docker import creates an image from a tarball.
- docker build creates image from Dockerfile.
- docker commit creates image from a container.
- docker rmi removes an image.
- docker history shows history of image.
- docker tag tags an image to a name (local or registry).
CheatSheet: on ii.icmp.co
Comments
Post a Comment