Docker Quick Reference

Updated by Linode

Contribute on GitHub

View Project | View File | Edit File


Docker Syntax Description
curl -sSL | sh The Docker maintained installation script
for Debian or Ubuntu.
sudo yum -y install docker The install command for Centos 7
or Fedora 21 and up.
sudo service docker start For Centos 7 and Fedora 21 after install,
Docker must be started.

Docker Hub

Docker Syntax Description
sudo docker search searchitem Search Docker Hub for images. Replace
searchitem with a search-able term.
sudo docker pull user/image Downloads an image from Docker Hub.
sudo docker push user/image Uploads an image to Docker Hub.
A Docker Hub username is necessary.

Using Containers and Images

Docker Syntax Description
sudo docker run -t -i user/image Runs an image, creating a container and
changing the command prompt
to within the container.
sudo docker run -p 80:3000 -t -i user/image Similar to the command above
but with port forwarding.
ctrl+p then ctrl+q From the container’s command prompt,
detach and return to the host’s prompt.
sudo docker attach 1aa Changes the command prompt
from the host to a running container.
Replace 1aa with a container ID.
sudo docker ps -a List all container instances, with their ID,
and status.
sudo docker images Lists all images on the local machine.
sudo docker rm -f 1aa Delete a container.
Replace 1aa with a container ID.
sudo docker commit 1aa user/image Save a container as an image.
Replace 1aa with a container ID.

Image Creation

Docker Syntax Description
FROM ubuntu:14.04
RUN apt-get update
Create an empty directory
with a file named Dockerfile,
then insert this syntax.
From the new directory,
run the build command,
listed below.
sudo docker build -t sampleuser/ubuntu . Builds a Docker image
from a Docker file,
as shown above.

This guide is published under a CC BY-ND 4.0 license.