/docker

docker-notes

Primary LanguageDockerfile

docker

general notes on how to use docker

Going to just assume I'm using an ubuntu image or container the entire time

Pull an image
  • docker pull ubuntu

Run an image and log into the shell. -i makes it interactive. -t allocates a psuedo tty.
  • docker run -it ubuntu bash

Run an image but do not log into the shell
  • docker run -itd ubuntu bash

Show current active containers
  • docker ps

Show all containers
  • docker ps -a

For examples below, my container's name is silly_mcnulty

Show information about the container in json format. use grep to find specific fields.
  • docker inspect silly_mcnulty

Log into the container's shell that is already running
  • docker attach silly_mcnulty

Stop the container
  • docker stop silly_mcnulty

Restart a container (using docker ps -a to show the non running container)
  • docker restart silly_mcnulty

Create an image with preconfigured settings from an already created instance (i.e. - you installed apache2 and want to always launch a container with it already running)
  • docker commit -m 'apache2 installed and running' -a lucassha silly_mcnulty ubunapache:v1

-m for the message. -a for the username. last portion is the name of the new image.


Create a port passthrough during bootup of an image. Use elinks to check it's functional.
  • docker run -dp 2345:80 nginx