![]() We did this to write the proper configuration file and add it to the Docker image started by Compose. In the previous article, we built a new image for Ghost. This is particularly useful if you use Compose in conjunction with Swarm and run your application in a cluster of Docker hosts. In a future post, we will look at the `scale` command, which starts multiple containers of a specific service. If you make changes to an image or want to rebuild an image, make sure that your containers are indeed taking into account your changes. If you only stop containers, they will be restarted without changes. $ docker-compose downĭuring testing, bringing down the entire application is very useful and avoids confusion. Finally, to bring down the entire application and remove the containers, images, volumes, and networks entirely, use the `down` command. There are lots of commands make sure you check the usage and experiment. The Docker `exec` command can be used via the Compose `run` command for instance, to run `/bin/date` in your ghost service, do the following: $ docker-compose run ghost /bin/date Mon Mar 21 10:16: Restarting services might be needed if there is a dependency between them and one stopped because another one was not ready yet. The name of the service is the name you gave it in your Compose file. You would bring it back up with `start` or `restart`: $ docker-compose start ghost For example, if you wanted to stop one of the services in your application, you would use `stop`: $ docker-compose stop ghost The most interesting point about these Compose commands is that you can manage individual services. We saw `ps` already, which is an equivalent to `docker ps`. The complete usage of the command will return, and you will see many more commands than just `up`. Now, enter `docker-compose -h` at the command line. ![]() ![]() If you had an application in a file with a different name, you could specify it with the `-f` option like `docker-compose -f otherfile.yaml up`. The second particularity is that Compose automatically looked for your application in the file `docker-compose.yml` or with the `.yaml` extension. This is helpful when you start writing your Compose file and you need to see why some containers may not be starting. If you omit it, then `docker-compose` will not return, and you will see the logs of the two containers in stdout. The `-d` option made the `docker-compose` command return. Let’s first look at what this does and how you could modify it. Last time I showed how to bring up the application with the single `docker-compose up -d` command. In part two of this Docker Compose series, I will look at a few Docker Compose commands to manage the application, and I will introduce Docker Volumes and Docker Networks, which can be specified in the YAML file describing our Compose application. ![]() In my previous article on Docker Compose, I showed how to build a two-container application using a MySQL container and a Ghost container using official Docker hub images. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |