Docker Compose does not allow the use of local images

The following command does not work, trying to pull an image from the Docker Hub:

$ docker-compose up -d Pulling web-server (web-server:staging)... ERROR: repository web-server not found: does not exist or no pull access 

But I just want to use a local version of the image that exists:

 $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE web-server staging b94573990687 7 hours ago 365MB 

Why doesn't Docker search among locally stored images?


This is my Docker Compose file:

 version: '3' services: chat-server: image: chat-server:staging ports: - "8110:8110" web-server: image: web-server:staging ports: - "80:80" - "443:443" - "8009:8009" - "8443:8443" 

and my .env file:

 DOCKER_HOST=tcp://***.***.**.**:2376 DOCKER_TLS_VERIFY=true DOCKER_CERT_PATH=/Users/Victor/Documents/Development/projects/.../target/docker 
+36
source share
4 answers

In general, this should work when you describe it. Tried to reproduce it, but it just worked ...

Folder structure:

 . β”œβ”€β”€ docker-compose.yml └── Dockerfile 

Docker file contents:

 FROM alpine CMD ["echo", "i am groot"] 

Image of assembly and tags:

 docker build -t groot . docker tag groot:latest groot:staging 

with docker-compose.yml:

 version: '3.1' services: groot: image: groot:staging 

and run docker-compose:

 $ docker-compose up Creating groot_groot ... Creating groot_groot_1 ... done Attaching to groot_groot_1 groot_1 | i am groot groot_groot_1 exited with code 0 
+49
source

In your docker-compose.yml you can specify build: . instead of build: <username>/repo> for local assemblies (instead of extracting from docker-hub) - I still can’t verify this, but I suppose you can make relative paths for several services to the docker-compose file.

 services: app: build: . 

Link: https://github.com/gvilarino/docker-workshop

+12
source

You may need to change your image tag so that the two parts are separated by a slash / . Therefore, instead of

 chat-server:staging 

do something like:

 victor-dombrovsky/chat-server:staging 

I think there is some logic for the Docker tags, and the "one piece" tags are interpreted as official images coming from DockerHub.

+7
source

Adding @Tom Saleeba's answer,

I still got errors after marking the container with "/" (for example: victor-dombrovsky/docker-image:latest ) He continued to search for the image from the remote docker.io server.

 registry_address/docker-image 

It seems that the URL before "/" is the registry address, and after "/" is the image name. and without "/", docker-compose by default searches for an image from remote docker.io.

This seems to be a known bug with docker-compose

Finally, I earned money by running the local registry , moving to the local registry with the registry tag and pulling the image from the local registry.

 $ docker run -d -p 5000:5000 --restart=always --name registry registry:2 $ docker tag your-image-name:latest localhost:5000/your-image-name $ docker push localhost:5000/your-image-name 

and then change the image URL in the Docker file:

 version: '3' services: chat-server: image: chat-server:staging ports: - "8110:8110" web-server: image: localhost:5000/your-image-name #####change here ports: - "80:80" - "443:443" - "8009:8009" - "8443:8443" 

Similarly for the chat server.

+1
source

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


All Articles