Cheatography
https://cheatography.com
Commands to control docker and related technologies
Building Images
|
Build a new image from the source code at PATH docker build -t myimg .
|
|
Suppress the output generated by containers |
|
Remove intermediate containers after a successful build |
|
Repository name (and optionally a tag) for the image |
Examples:
Simplest possible build instruction:
docker build .
Name image and tag as v1.5:
docker build -t myorg/myimg:1.5 .
Misc useful commands
attach |
Attach to a running container |
cp |
Copy files/folders from a container's filesystem to the host path |
create |
Create a new container |
exec |
Run a command in a running container |
images |
List images |
export |
Stream the contents of a container as a tar archive |
import |
Create a new filesystem image from the contents of a tarball |
inspect |
Return low-level information on a container or image |
kill |
Kill a running container |
load |
Load an image from a tar archive |
logs |
Fetch the logs of a container |
port |
Lookup the public-facing port that is NAT-ed to PRIVATE_PORT |
ps |
List containers |
pull |
Pull an image or a repository from a Docker registry server |
push |
Push an image or a repository to a Docker registry server |
rm |
Remove one or more containers |
rmi |
Remove one or more images |
save |
Save an image to a tar archive |
search |
Search for an image on the Docker Hub |
start |
Start a stopped container |
stop |
Stop a running container |
top |
Lookup the running processes of a container |
wait |
Block until a container stops, then print its exit code |
Run docker COMMAND --help
for help on the command.
|
|
Running Docker
|
starts a process with its own file system, its own networking, and its own isolated process tree docker run -itP image
|
|
name the container docker run --name=somename org
|
|
terminal interface |
|
interactive session |
|
daemon Mode |
|
publish all exposed ports |
|
expose specific port -p ip:hostport:containerport
|
|
remove intermediate images |
|
bind mount a volume -v /host:/container
|
Examples:
run an interactive session:
sudo docker run -P --name=somename image
run container in background, on port 80:
sudo docker run --d -v /etc/appdata:/data -p 0.0.0.0:80:8080 --rm nginx
|
|
Dockerfiles (for creating images)
|
set base image for this image FROM <image>:<tag>
|
|
The author of the image MAINTAINER <name>
|
|
execute commands in new layer RUN <command>
RUN ["executable", "param1", ...]
|
|
provide default for an executing container CMD ["executable","param1",...]
|
|
add metadata to image LABEL <key>=<value> <key>=<value>
|
|
listen on the network ports EXPOSE <port> [<port>...]
|
|
set the environment variables ENV <key> <value>
ENV <key>=<value> <key>=<value>
|
|
copies new files from <src>
and adds them to the container at <dest>
. ADD <src>... <dest>
|
|
configure container to run as an executable ENTRYPOINT ["exe", "arg"...]
|
|
create externally mounted volumes VOLUME ["/data"]
|
|
sets the user name or UID to use when running the image USER<user>
|
|
sets working dir for any RUN
, CMD
, ENTRYPOINT
, COPY
and ADD
instructions: WORKDIR /path/to/workdir
|
|
adds a trigger instruction for execution when image is used as base of another build ONBUILD [INSTRUCTION]
|
|
Created By
aabs.wordpress.com
Metadata
Favourited By
and 6 more ...
Comments
javafun, 12:57 6 Dec 16
PDF link is not working
Add a Comment
Related Cheat Sheets