Skip to content

Instantly share code, notes, and snippets.

@dtuite
Last active November 17, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dtuite/b595308c11e5bd251117 to your computer and use it in GitHub Desktop.
Save dtuite/b595308c11e5bd251117 to your computer and use it in GitHub Desktop.
Basic Docker Commands

Docker Basics

There are two programs:

  1. The docker daemon - a server process which manages all the containers
  2. The docker client - a remote control for the daemon

You can list the commands of the docker client by typing docker with no arguments.

You can use container images which have been created by other people. You find them online in the docker index. You can search for images using docker search [keywords].

Container images are downloaded using docker pull [image name].

Containers are unstarted by default. You can run commands in a container using the syntax:

docker run [image name] [command to run]

For example, we can install the program "ping" in the container with the command (note: the -y flag instructs apt-get to not ask us to confirm the changes we're about to make):

docker run learn/tutorial apt-get install -y ping

The changes we have made to the container are not yet saved. To save the container, we first need to find it's id:

docker ps -l

Once we have the first few chars of the id, we can save the container with a new image name using:

docker commit [id] [new image name]

We can now run the ping command on our container using:

docker run learn/ping ping www.google.com

We can use docker ps and docker inspect [container id] to learn about available containers.

We can share images using docker push [image name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment