Deploying docker-compose containers

前端 未结 1 1005
春和景丽
春和景丽 2020-12-17 23:17

I\'m trying to deploy an app that\'s built with docker-compose, but it feels like I\'m going in completely the wrong direction.

  1. I have everything working local
相关标签:
1条回答
  • 2020-12-17 23:35

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

    The app service didn't specify a repository name or tag, so when I ran docker-compose up on the server, it just tried to build the Dockerfile in my app's source code directory (which doesn't exist on the server).

    I ended up solving the problem by adding an explicit image field to my local docker-compose.yml.

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

    Then created an alternative compose file for production:

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

    After running docker-compose build locally, the web service image is built with the repository name my-private-docker-registry and the tag latest.

    Then it's just a case of pushing the image up to the repository.

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

    And running docker pull, it's safe to stop and recreate the running containers, with the new images.

    0 讨论(0)
提交回复
热议问题