Skip to content

Instantly share code, notes, and snippets.

@bearzk
Last active March 6, 2023 12:56
Show Gist options
  • Save bearzk/e6d0aab8cf8ec83d2fb78bb1b48a5d26 to your computer and use it in GitHub Desktop.
Save bearzk/e6d0aab8cf8ec83d2fb78bb1b48a5d26 to your computer and use it in GitHub Desktop.
tiny crash course to get containers running

docker cli crash course

TL;DR

you have docker installed on your system, you want to install the services we use for API project

$ docker run -d --name mongo4.4 -p 27017:27017 mongo:4.4

$ docker run -d --name rabbitmq -p 4369:4369 -p 5671-5672:5671-5672 -p 15671-15672:15671-15672 -p 15691-15692:15691-15692 -p 25672:25672 rabbitmq:3.8-management-alpine

$ docker run -d -p 6379:6379 --name redis redis

RUN a container based on an image

$ docker run -d -p <host port0>:<container port1> --name <name for container> <image:[version]>

run a container for image:[version] in daemon mode, expose its port1 as port0 on host machine, give it a name <something>

START an existing named container

$ docker container start <containerName|containerId>

STOP a named container

$ docker container stop <containerName|containerId>

list all containers

$ docker ps -a

extras

remove containers

$ docker rm <containerName|containerId>

remove dangling images

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