Skip to content

Instantly share code, notes, and snippets.

@patmigliaccio
Created August 1, 2020 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patmigliaccio/6837d76a1c9ef797872bf651ebbec343 to your computer and use it in GitHub Desktop.
Save patmigliaccio/6837d76a1c9ef797872bf651ebbec343 to your computer and use it in GitHub Desktop.
A generic set of commands to reference when working with Docker

Docker Commands

A generic set of commands to reference when working with Docker

Containers

Create Container

$ sudo docker run --name mydb -e MYSQL_ROOT_PASSWORD=pass -d mysql:latest

-d: detach process --name: container name -e: environment variable

Stop Container

$ docker stop mydb

List Containers

$ docker ps

Container Info

$ docker inspect <container name>

IP Address

$ docker inspect <container name> | grep IPAddress

Tail Logs

$ docker logs --tail 50 --follow --timestamps mediawiki_web_1

Images

Build image

$ docker build -t <IMAGE_NAME> .

See all images

$ docker images

Remove image

$ docker rmi nginx

Docker Compose

Spin up docker instancres from a docker-compose.yml file.

$ sudo docker-compose up -d

-d predicate detaches the docker process

Spin down docker instances to their volumes to persist db.

$ sudo docker-compose down

--volumes predicate will destroy persisting volumes

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