Skip to content

Instantly share code, notes, and snippets.

@congwenma
Created September 13, 2018 20:09
Show Gist options
  • Save congwenma/aa5e3c84e36681d61184e21fbb8730d4 to your computer and use it in GitHub Desktop.
Save congwenma/aa5e3c84e36681d61184e21fbb8730d4 to your computer and use it in GitHub Desktop.
learn docker notes

docker container run --publish 80:80 nginx

  1. Downloaded latest image nginx from Docker Hub
  2. Started a new container from that image
  3. Opened port 80 on the host IP (1st 80)
  4. Routes that traffic to the container IP, port 80 (2nd 80)

docker container run --publish 80:80 --detach nginx

  • --detach tells docker to run it in the background and we get back(it returns) unique container id of our container

docker container ls

  • list all containers running

Stopping container

docker container stop

  • stops the container

docker container rm -f 675 697 360

  • removes container
  • -f removes even running container

intersesting fact: docker container names when not specified will randomly

generatre an adjective and a famouse scientist, e.g. practical_brown

docker container run --publish 80:80 --detach --name webhost nginx

Viewing Logs

docker container logs webhost -f

  • webhost is the container name
  • -f - tailing

Check processes running in the container

docker container top webhost

Interesting fact: nginx has a master process and it spins up worker

process based on configuration

View help

docker container --help

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