aboutfert.blogg.se

Dockerfile composer
Dockerfile composer






In this example, I am mapping 8081 on my local machine to 8081 on the container like so: version: '3' Please notice the dash, a dash in a yaml file is how we specify an array. Then you want to specify all the different ports that you want open on this container. Also, notice for one service I am grabbing an image, but for another service I am telling docker-compose to look inside the current directory to build the image that will be used for the second container. Please notice the indentation, very important. After that, you have to add: version: '3'

dockerfile composer

That tells Docker the version of docker-compose you want to use. So for your docker-compose.yml file, you would want to start the first line like so: version: '3' So you will have separate containers, let's say, one is redis-server and the second one is node-app, and you want that created using the Dockerfile in your current directory.Īdditionally, after making that container, you would map some port from the container to the local machine to access everything running inside of it. Once created, you have to feed it to the docker-compose cli and it will be up to the cli to parse the file and create all the different containers with the correct configuration we specify. You are not just going to copy paste them into the yaml file, there is a special syntax. To make use of docker-compose, you need to encode the commands you were running before into a docker-compose.yml file.

dockerfile composer

The purpose of docker-compose is to function as docker cli but to issue multiple commands much more quickly. Docker-compose exists to keep you having to write a ton of commands you would have to with docker-cli.ĭocker-compose also makes it easy to startup multiple containers at the same time and automatically connect them together with some form of networking.








Dockerfile composer