![]() So, now we can add the -build flag to our docker-compose command to force the rebuild of the image: docker-compose up -build. The build step sets the context to the current directory and enables us to build our image using the Dockerfile defined in that context. To automate this step we can modify our docker-compose.yml file with the build step: command, and then run the docker-compose up command in order to apply those changes. We would need to build the image again with the docker build -t codemazeblog/accountownerapp. But if we make some changes to the application or the Dockerfile, Compose would still run the image we’ve built before those changes. Ok, so until now, we’ve just run the existing image with docker compose. To make sure you release the resources you need to run docker-compose down. One thing to note here is that if we quit a container with Ctrl+C, it won’t kill the container or the network created by Compose. In that case, we would need to stop the service(s) with docker-compose down. We can run our services in the background by adding -d flag: docker-compose up -d. We’ve described what image we want to run and which port we need to expose. In our case, this is just our application, but soon we’re going to add one more service to it. ![]() Now the only command we need to run to achieve the same result is docker-compose up.Īs you may see, the docker-compose.yml contains the set of services. To jog your memory, we used to run our application like this: docker run -rm -it -p 8080:5000 codemazeblog/accountowner:runtime. This is the simplest of Compose files, and it’s practically the same thing we did with the docker run command in the last part of the series. Once we’ve created the file, we can start adding some commands to it: So let’s start by adding a docker-compose.yml file to the root of our solution. This file is usually called docker-compose.yml and it’s placed at the root of our project. Adding Docker Compose to Our ApplicationĬompose relies on a YAML file. ![]() Let’s drill down into it and see how awesome Compose can be. NET/C# content and get paid? > JOIN US! << Wanna join Code Maze Team, help us produce more awesome.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |