3000
and when the URL /
is hit, it prints
Hello World!
Dockerfile
is a set of instructions that tells Docker how to get
our app working in our environment.
node_modules
to be present while running the application. Prefer to
opt-in for multistage builds whenever possible.
.dockerignore
file to ignore certain prebuilt binaries and non-project-related
stuff being copied from our local to the Docker container.node_modules
since when installing dependencies, few libraries might build
binaries depending on your platform. We don’t want them to be copied since it might replace the binaries built inside
the container itself while running npm ci
, causing the application to break or misbehave.
GoLang
.dockerignore
file for reference:Django (Python)
.dockerignore
file for reference:Ruby on Rails
.dockerignore
file for reference:node-app
image for platform linux/amd64
and tags it as latest
. If you are locally testing
your application, you can skip the platform
key to build the images
-it
: enables interactivity with TTY--rm
: to tell the Docker Daemon to clean up the container and remove the file system after the container exits--name node-app
: Name of the container node-app
.-e PORT=3000
: Sets the environment variable PORT in docker 3000
.-d
: Runs the container in detached(background) mode. You can skip the flag to see the logs directly in your terminal
window.-p 3000:3000
: Maps port 3000 on your host to port 3000 in the container.node-app
in the end is the name of the image3000
of the container to port 3000
on your local machine. Once the
service is up, visit http://localhost:3000
to see the app we built running.
Hurray 🎉. Now we have package our app for production use using docker.