Technology

Docker Templates

by
on
4/7/2021
Docker Templates

You are working on a React App and you are thinking about Dockerizing it. Great! Docker is a tool for developers to build and run their applications. However, it can get complicated if you don't know exactly what you're doing. We at NerdCloud are here to help you through this process.

Docker is a platform as a service (or PaaS, for short) that uses OS-level virtualization to deliver software in packages. In simple terms, Docker is a software platform that simplifies building, running, managing, and distributing applications. Each software is in a package called a container, and containers are isolated from one another. 

Using Docker is a smart solution for your app integration. You can use Docker to make your different repositories talk to each other on your local computer and your public domain. Docker is a free and open-source platform, and it runs on Red Hat Enterprise Linux, SUSE Linux Enterprise Server, Oracle Linux, Ubuntu, Windows Server 2016, Azure, and AWS.

If you need an introduction or a refresher on Docker, here is a YouTube playlist by LearnCode Academy for you.

If you follow the tutorial found on Docker's documentation, you will be able to download a Dockerfile template and run it locally. However, you might want to create some templates by yourself without following the documentation - and we're here to help you.


Creating a Dockerfile

If you're thinking about dockerizing your application, you might already have a full project written out and you don't want to redo it within Docker. The solution for that is to push your built local project into Docker.

For that to happen, you need to create a Dockerfile in your project root. A good start for you is something like this:

# Comment
FROM nginx:alpine
COPY <src> <dest></dest></src>
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

FROM means specifying the Parent Image from which you are building your own Docker container from. This always needs to be the first command you have on your file.

COPY is going to copy new files or directories from <src> and adds them to your container at the path <dest>. </dest></src>

EXPOSE is the port you would like to make your project run on. 

CMD would run the commands that you would usually run on your localhost to have your app run. It can be something like "npm install", "npm run-start", or any commands necessary to start your project.


This is a basic template that you can start building off to make sure it attends to your needs. If you need additional help or guidance with anything technology-related, we at NerdCloud are here to tend to your needs. Just sign up to NerdCloud and we’ll contact you by email right away. We will help you with Docker and any other software issues you might face.