Docker

Docker is a way to normalize and simplify deployment of software.

Glossary

Word Description
Daemon (dockerd) Listens for API requests and manages docker objects.
Client (docker) CLI, how most users interact with Docker.
Desktop A GUI that makes building and sharing images easier.
Image A read-only configuration that can be deployed onto a machine running Docker.
Registry A place to store Docker images. Docker Hub is a public registry.
Container A runnable version of an image.

Shamelessly taken from Eric Pearson/@nyloneric, as I haven't documented my own process yet.

Create a Container

Make the thing: https://flaviocopes.com/docker-node-container-example/

Create a simple Node.js Hello World Docker Container from scratch

You will run into errors, so:

Container: docker exec -it <container id> /bin/bash``docker run -p 49160:8080 -d <your username>/node-web-app

Docker Hub Dockerizing a Node.js web app | Node.js I also really like Mosh Hamadani tutorials

Make a dockerfile

FROM node:14

COPY package*.json ./
COPY tsconfig.json ./
COPY yarn.lock ./

RUN yarn install

COPY . .

RUN yarn build

EXPOSE 3000

CMD ["yarn", "start"]

Build

$ docker build -t NAME .

Run

$ docker run -dp 3000:3000 NAME

The package should now be available on your local machine

References

  1. https://www.freecodecamp.org/news/the-docker-handbook/
  2. https://docs.docker.com/get-started/overview/
  3. https://scribe.rip/swlh/what-exactly-is-docker-1dd62e1fde38

Last modified: 202401040446