Skip to content

Instantly share code, notes, and snippets.

@Blankeos
Created February 4, 2025 14:26
Show Gist options
  • Select an option

  • Save Blankeos/8f9128918a25365c58ba668cfc74db6f to your computer and use it in GitHub Desktop.

Select an option

Save Blankeos/8f9128918a25365c58ba668cfc74db6f to your computer and use it in GitHub Desktop.
Docker for noobs

I'm writing this because I keep forgetting Docker.

Make sure you have Docker Desktop.

All you need to know from start to finish:

  1. Image (a blueprint) -> Container (a running service based on the image) That's it!
  2. First know how to build images.
  3. Then know how to run containers from images.

Building an Image

# First write a Dockerfile... (you do it)

# Then in the same folder, run the commands: 
docker build . -t 'image-name'
# or
docker build . --tag 'image-name'

# After running, you will see the image under "Images" in Docker Desktop.

Running Containers

# There are a bunch of ways, but here's my recommended command for you, for no ambiguity:
docker run -d -p 3000:3000 --name 'container-name' 'image-name'
# To note:
# - 3000 (on the left is the host machine, your computer, what you can access in your browser)
# - 3000 (on the right is the Docker, the port where your service is running)
# 'container-name' - use any container name, it will show up on the Docker Desktop under "Containers"
- 'image-name' - use the image name you used to build earlier.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment