Docker
Overview
Working as a team consists several people might lead to different preferences of environment used by each of the developer. Having different preferences in the local machine might be reasonable, but in order to deliver a product, having different environment preferences might lead to errors in production. So, here it’s a new trend called as “Docker”.
What is Docker
Docker is a ‘container like’ tool used to make the process of creating, deploying, and running application easier. Basically, docker is like a whole machine, whole virtual machine precisely. This virtual machine will be filled with requirements of the project we are developing, such as framework, language used, supporting application, and other supporting sub system.
How to use docker ?
Because the use of docker is such as virtual machine, we can simply run our application on the docker. Normally we call it inside our cli, gitlab-ci.yml for example.
In the example above, the docker used is “dhiptary/b22020". And the script of the application we use to run on the docker is “‘flutter analyze”.
How to compose docker ?
Prerequisite:
- Have docker installed inside your machine.
- Have dockerhub(or other platform) connected to your machine.
- Have a good connection. (normally a docker would take space around 1 GB, so that in order to have a good experience in composing docker, you might need a good connection)
There are several steps we need to follow to
1. Create dockerfile.
2. Compile dockerfile.
3. Push docker image.
Create dockerfile
To create a dockerfile, we only need to create a file named Dockerfile. Inside the dockerfile, you need to put some commands related to “what will your machine be filled with”. Here’s an example.
“FROM” is used to tell the image which our docker will use.
“RUN” is used to run commands, just like normal terminal commands, we only need to add “RUN” at the beginning of the line. We do not use sudo here.
“ENV” is used to set environmental variables.
With those 3 commands, you can create a Dockerfile.
Compile dockerfile
From your directory of dockerfile, run this command.
$ docker build -t yourusername/repository-name
The output of command above is a new docker image named yourusername/repository-name.
$ docker images
Push docker image
after getting the docker image, we can share the docker so that the other developer in our team can use it accordingly.
$ docker push yourusername/repository-name:versionNumber
Docker in our team
In my team, the most current docker image is published in https://hub.docker.com/r/dhiptary/b22020. The instructions above are the ones that my team used to create the docker*. After so many tries, we finally created the docker which we need for our project. It’s good to know what are the requirements of our docker image needs, so that there are less things to be worried about. Trough the process, there were so many obstacles that we met, here are the history of our docker image.
from picture above, the <none> ones are just the same as the dhiptary/b22020 but i did not tag them because of some reason.
Yea, here’s all i got for docker story :) see you next time :)
*with different dockerfile of course
References:
docker.com