Skip to content

Instantly share code, notes, and snippets.

@dtothefp
Last active February 22, 2017 01:49
Show Gist options
  • Save dtothefp/302f0306e5748e0f565e24aaba3e566e to your computer and use it in GitHub Desktop.
Save dtothefp/302f0306e5748e0f565e24aaba3e566e to your computer and use it in GitHub Desktop.
docker images
docker search <name*>
docker inspect <image_name>
docker pull <name:tag,name,id>
docker ps # what is running
docker ps -a # what containers ran in the past
docker run -it # interactive, terminal
docker run -d # run in background
docker run -d <some_cmd> -e <some_script> # execute
docker attach <container_name> # attach to process of running container
docker restart <container_name> # can use `start` in place of `restart`
docker exec -it <container_name> <cmd> # execute in running container without effecting runnign process
docker rmi <id_name_name:tag> # remove image, only if has not been run in past
docker rmi -f <id_etc...> # for removes the image and containers that use base image
docker rm <name_id> # remove container that has been run previously
docker rm `docker ps -a -q` # removes all containers that were previously run, -q gives all id's
docker run -P # any ports exposed to container, make available through host OS
docker port <container_name> $CONTAINERPORT # list port mappings between host and container, can also use `docker ps`
docker run -p <host_port>:<container_port> # specify port to map between host and container
docker run -v /mnt/data <container_name> # creates a mount point at `/mnt/data`
docker run --v /home/user/www:/usr/share/nginx/html # mount host directory to container directory, allows for live updates on server into container
docker build -t <container>/<name> . # build a container using a dockerfile in the current directory
sudo docker exec -i -t jenkins /bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment