Image for post
Image for post

What is Docker?

Docker is a DevOps tool that allows people of all computer backgrounds(Mac, Windows, Linux, etc…) to collaborate on the same project without any environmental errors. It is fast and easy to implement. Once the environment is set up, then all it takes to be in the same environment is to run a simple line of code that the author creates.

How to start

The first goal that needs to be accomplished when first getting into docker is to obtain a personal domain from several different websites(I used Namecheap).

Image for post
Image for post
Image for post
Image for post
setting up A record

Where to go once this is complete

After the site is configured properly and it is accessible to anyone, then the next thing that needs to be completed is to start learning about Docker itself. Docker needs to be downloaded from Docker and if you do not already have an account, make one and follow the steps to create one.

Image for post
Image for post
Docker download page
Image for post
Image for post
Docker documentation page

The DockerFile is set up but how do I run it?

The way I learned to run is to exit from the text editor where the DockerFile is running and to open up a terminal. This is where a few lines of code can be executed to actually build the container. This first line that should be run is:

$ docker build -t USERNAME/IMAGE_NAME .
$ docker run --rm --name CONTAINER_NAME IMAGE_NAME

What’s next?

Once these few steps have been routined in your DockerFile skills then the fun start to be explored with some Docker knowledge. It’s a great practice to go onto an open code based platform to search what other peoples DockerFile looks like and to see what other people have been able to do. The best ones to look for, are those that are easily understandable and to be able to search questions that are thought up while reading through the code.

Now that you have more Docker knowledge

One good source to actually test your Docker skills is to set up your very own server! This can be achieved through many different platforms, but the one I used was DigitalOcean. Here you can set up your own server to have it set up with the “nameofyourproject.domainname” With using DigitalOcean it is good to also install CapRover in order to set up your server and point it to your DigitalOcean server. It only takes a couple of lines to install CapRover.

$ npm install -g caprover
$ caprover serversetup

Applying CapRover to your project

After you have set up your server, then it is a good time to set up your own repository with CapRover. For learning purposes, you can use a template that already has CapRover fully implemented to better understand how it is working by looking over the template. A key feature that you want to pay attention to when looking over a template, is to look for a ‘captain-definition’ file. This file tells CapRover how to deploy your application. Next, you should go to CapRover and create a new App and call it what you named your repository. Once you do that, you should go to your configurations settings and link your database. After your database is linked, go back to your project and make sure all of your changes have been committed and run the command:

$ caprover deploy --default 
$ sshroot@<ip_address>
docker exec -it $(docker ps --filter name=srv-captain--myappname -q) /bin/sh

Written by

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store