Deploying Docking Containers

I am trying to deploy an application that was built using docker-compose, but it looks like I'm going in the completely wrong direction.

  • I have everything that works locally. docker-compose up displays my application with the appropriate networks and hosts.
  • I want to be able to run the same container and network configuration on a production machine, just using a different .env file.

My current workflow looks something like this:

 docker save [web image] [db image] > containers.tar zip deploy.zip containers.tar docker-compose.yml rsync deploy.zip user@server ssh user@server unzip deploy.zip ./ docker load -i containers.tar docker-compose up 

At this point, I was hoping to run docker-compose up again when they get there, but trying to rebuild the containers according to the docker-compose.yml .

I have a clear feeling that I have missed something. Should I post through my full application and then create images on the server? How would you start creating containers if you saved / downloaded images from the registry?

+5
source share
1 answer

The problem was that I used the same docker-compose.yml file during development and production.

The application service did not specify a repository name or tag, so when I ran docker-compose up on the server, it just tried to create a Docker file in the application source directory (which does not exist on the server).

I decided to solve the problem by adding an explicit image field to my local docker-compose.yml file.

 version: '2' services: web: image: 'my-private-docker-registry:latest' build: ./app 

Then an alternate file was created to create:

 version: '2' services: web: image: 'my-private-docker-registry:latest' # no build field! 

After launching docker-compose build local web service image is created with the repository name my-private-docker-registry and the latest tag.

Then this is just a case of clicking an image on a repository.

 docker push 'my-private-docker-registry:latest' 

And by launching docker pull , you can safely stop and recreate running containers with new images.

+2
source

Source: https://habr.com/ru/post/1263384/


All Articles