Skip to content

Instantly share code, notes, and snippets.

@claritee
Last active December 2, 2017 09:28
Show Gist options
  • Save claritee/ea97eb04e94e623790bc46244c8de2d9 to your computer and use it in GitHub Desktop.
Save claritee/ea97eb04e94e623790bc46244c8de2d9 to your computer and use it in GitHub Desktop.
Notes/Guide to docker

Docker notes

What are these?

Notes about docker and commands commonly used. Putting together an easy to follow reference guide.

Installation

Check the version:

docker -v

Basics

Pull Image

docker pull kitematic/hello-world-nginx

Run

Create and run

docker run kitematic/hello-world-nginx

Port binding/forwarding

docker run -p 80:80 kitematic/hello-world-nginx

Named container

docker run -d -p 80:80 --name helloworld kitematic/hello-world-nginx

Note: -d is in detached mode

Start existing container

453411b0f57c

What's running

docker ps
docker ps -a #shows running & non-active containers

Stop a container

docker stop <container-id>
docker stop <container-name>

Executing Commands on the container

docker exec -it <container> /bin/bash

Note: the container must have /bin/bash installed.

E.g. You can try on this image https://hub.docker.com/_/ruby/

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