DEV Community

Kern Designs
Kern Designs

Posted on

3 1

Create a DockerFile

So you're interested in Docker? You came to the right spot. Today I'm going through what it is, a video tutorial on how to get started, and a tutorial on how to create a DockerFile.

What is Docker

Before you even install and try to run docker, you should probably understand what it is. Docker is a light-weight way of running a program through containers and microservices. Monolith Server Architecture is a thing of the past because we traditionally hosted resources in one environment. This made it versatile, but also heavy and very difficult to update changes. Microservices are used to split up tasks into specific operations. In the picture below, you can see all the small microservices one interface may be running on multiple machines. The whole functionality of a backend is now in thousands of containers all over the world.

Docker Image

Get started

You can follow this tutorial to learn more about how to run docker on your browser. Remember when copying and pasting into docker you may have to use ctrl shift p.

Create a DockerFile

  1. Run your GitHub repo in the docker playground.
  2. Run touch Dockerfile
  3. Select Editor to open the file system. You should see your file. Editor showing Dockerfile
  4. Double click on the Dockerfile in order to edit its contents.
  5. Paste in the basic information shown below.
# syntax=docker/dockerfile:1
FROM node:12-alpine
RUN apk add --no-cache python2 g++ make
WORKDIR /app
COPY . .
RUN yarn install --production
CMD ["node", "src/index.js"]
Enter fullscreen mode Exit fullscreen mode
  1. Run docker build -t getting-started .
  2. Start the app with docker run -dp 3000:3000 getting-started
  3. Open http://localhost:3000/. You should see a running app.

You now have a working Dockerfile! Congrats and keep coding!

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

Best practices for optimal infrastructure performance with Magento

Running a Magento store? Struggling with performance bottlenecks? Join us and get actionable insights and real-world strategies to keep your store fast and reliable.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️