Docker Compose does not allow to use local images

后端 未结 9 1787
-上瘾入骨i
-上瘾入骨i 2020-12-24 00:33

The following command fails, trying to pull image from the Docker Hub:

$ docker-compose up -d
Pulling web-server (web-server:staging)...
ERROR: repository we         


        
相关标签:
9条回答
  • 2020-12-24 00:57

    You might need to change your image tag to have two parts separated by a slash /. So instead of

    chat-server:staging
    

    do something like:

    victor-dombrovsky/chat-server:staging
    

    I think there's some logic behind Docker tags and "one part" tags are interpreted as official images coming from DockerHub.

    0 讨论(0)
  • 2020-12-24 01:00

    Version >1.23 (2019 and newer)

    Easiest way is to change image to build: and reference the Dockerfile in the relative directory, as shown below:

    version: '3.0'
    services:
      custom_1:
        build:
          context: ./my_dir
          dockerfile: Dockerfile
    

    This allows docker-compose to manage the entire build and image orchestration in a single command.

    # Rebuild all images
    docker-compose build
    # Run system
    docker-compose up
    
    0 讨论(0)
  • 2020-12-24 01:00

    For me putting "build: ." did the trick. My working docker compose file looks like this,

    version: '3.0'
    services:
      terraform:
        build: .
        image: tf:staging
        env_file: .env
        working_dir: /opt
        volumes:
          - ~/.aws:/.aws
    
    0 讨论(0)
提交回复
热议问题