This section explain more about the docker process and workflow. In order to install docker please follow these steps below:
- brew cask install docker
- Activate Docker via its ui whenever it finished its download
- brew install docker-compose
- Try to exchange your machine for a MAC or at least one that runs Linux distribution ... And do not try VMs for this (I know you thought about it ...)
- If you use windows 10, just go to Docker website and download it
- If not windows 10 user, really consider step 1, else, try the chocolatey (windows apt-get), and make the installation through it
- Follow this reference -> Study of Docker on Windows Machines
The dockerfile is the script that will build each docker image you need.
- At root level of a project create a extensionless file Dockerfile
- Write your needed commands there to build your adequate image, e.g. Dockerfile
- Probably there will be things you won't want to upload when creating your container, one of them are the project dependencies, so create a file .dockerignore like .gitignore, e.g. dockerignore
- In order to build the container using the Dockerfile, issue this command on your terminal:
docker build <container name> <path to the Folder containing the Dockerfile>
- Now that it is built, lets run the container:
docker run -d -p <container Port>:<host Port> <container name>
- Now, if everything went well on the aforementioned steps, you should be able to test the service dockerized through the localhost and the ports you mapped. E.g., normally we choose common ports like 3000 or 8080 for mapping.
- Example:
docker build -t project/ui .
docker build -t project/backend .
docker run -d -p 3000:3000 project/backend
docker run -d -p 8080:8080 project/ui
- Now it is possible to check these services on
localhost:3000
andlocalhost:8080
Now that we have everything setup and ready, we can compose and manage the container creation process through files and a reduced set of commands ...
- Createa a new folder
- Get inside it
- Pick each of the dockerized projects github(svm) references
- On terminal, type:
git submodule init
- On terminal, type:
git submodule add <github reference either ssh or https>
- On terminal, whenever any of those repositories added before receive an update, please type:
git submodule update
- Now that the environment is setup, lets make the one file that will make every magic of docker-compose a reality, create a new file called docker-compose and its extension will yml(yet another markup language)
- Edit the yml as we edited in here -> docker-compose
- As you saw there, we declared the services we dockerized, the path where the dockerfile can be found (
build
), the image that will be generated through their Dockerfiles process (image
) and finally the port mapping (ports
), i.e. in which port of the container the service will be exposed and in which port of the host the docker's port will be exposed. - Now that everything is mapped and defined, go to the folder where the yml file is in and issue the following commands:
docker-compose up
- In order to stop and clear the containers created, issue the following command:
docker-compose down
- Install Docker and Docker Compose
- Go to the folder and issue the command
git submodule init
- Issue the command
git submodule update
- Issue the command
docker-compose build
- Issue the command
docker-compose up
- Issue the command
docker-compose down
- Do all needed modification on the submodules and commit and push inside their folders, and everything will be alright