For the homework#3 of this week, I had a chance to practice on the docker compose. However, excepting for the little knowledge that I learned from the activity 10 in class, I had no clue what docker compose was. Therefore, I wanted to learn more about docker compose to get a better understanding and also learn how to write a docker compose file.
Docker Compose Tutorial: advanced Docker made simple is one of the resources that I find useful to help me get an overview about the docker compose, how to write an .yml file, and how to run the .yml file with docker-compose commands. Through the website, I know that docker compose is used to define and run multi-container Docker applications; and I also get an idea of what components should be included in a .yml file to create a docker container. Specifically, to create a container service, we need some entries like build, link, image, ports, volumes, command, environment, etc.; and the function of each entry is also described in detail on the website. For example, back to the activity 10 in class, now I am able to convert the docker command given in the below picture to an equivalent .yml file.
As shown in the above docker command, my .yml file will create a container named cache using the image named redis with the tag of 6.0.8. This container has internal port 6379 connecting to the external port 11000, and it also mounts two directories of ./redis.conf and /etc/redis.conf. So, the components that should be included in my .yml file are version, services, web, image, ports, and volumes.
First, version is to define which version of docker compose that I am using. Services is used to define all different containers that I want to create. Web is use to present the container name, in this case, I will replace web with cache. Image will represent which image is used to create the container (redis:6.0.8). Ports is used to map the external port with the internal port (11000:6379). Volume is used to mount the source directory, ./redis.conf, with the destination directory, /etc/redis.conf.
In short, in my opinion, I believe the website that I found is a good resource, because from it, I can find really useful information about docker compose, such as definition of docker compose, how to write .yml file, and docker-compose commands. Thanks to this resource, I am more familiar with .yml file and docker-compose commands. Especially, I used what I learned from this website to do my homework 3.
From the blog CS@Worcester – T's CSblog by tyahhhh and used with permission of the author. All other rights reserved by the author.