Following the Docker activities in class, I found docker-compose quite confusing. I decided to use that as an opportunity to look for some other resources that explains the concept briefly but detailed so I can understand the term well. I finally settled on this blog that gives a tutorial on docker-compose. I like the fact that all concepts have been covered and explained simply. I also see some terms that in found confusing during class activities defined and explained. I like how it starts by giving a walkthrough of docker in general and then introduces docker-compose so the connection is clear and as a reader, you would not get lost.
This blog talks about the fundamentals of docker. It explains docker-compose as a docker tool used to define and run multi container applications. It talks about the features of docker-compose, structure of a docker-compose file and explains some of necessary keywords found in the structure. It gives images of structure of docker-compose file and images on docker-compose and docker to differentiate them. Blog also explains some docker-compose commands.
I learned in this blog that you can start using docker-compose with docker files by defining your apps environment using a docker file, defining the services for your app so that they can run in an isolated environment and start the app by running docker-compose. Docker-compose can be added to a pre-existing project and to your workspace if you add a docker file.
Docker-compose files can work by applying multiple commands that are declared within a single .yml configuration file. The compose file consists of keywords that make up the structure such as services, ports, volumes, build, etc. In class, these keywords were not clear to me. However, in this blog I learned that version denotes the version of the Docker-compose which is usually the latest version. All containers created are defined in services and docker composes will create containers based on the name we provide under this section. Build specifies the location of the docker file and ports map the container’s port to the host machine. The image keyword allows to run a service using a pre-build image by specifying the image location. Understanding of these concepts really helped me in the recent homework assignment.
I also learned that the purpose of the build in docker-compose build is to get images ready to create containers but this will be skipped if a service is using a pre-built images. I always thought that docker compose up builds images and run containers but little did I know that it also forks containers directly if images are already built.
I hope others find this blog helpful especially those that are new or beginners to the term, as it will give an insight of the term and that will help guide you through working with docker.