The following command fails, trying to pull 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, which exists:
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
web-server staging b94573990687 7 hours ago 365MB
Why Docker doesn't 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
You might need to change your image tag to have two parts separated by a slash
/
. So instead ofdo something like:
I think there's some logic behind Docker tags and "one part" tags are interpreted as official images coming from DockerHub.
In general, this should work as you describe it. Tried to reproduce it, but it simply worked...
Folder structure:
Content of Dockerfile:
Build and tag image:
with docker-compose.yml:
and start docker-compose:
Adding to @Tom Saleeba's response,
I still got errors after tagging the container with "/" (for ex:
victor-dombrovsky/docker-image:latest
) It kept looking for the image from remote docker.io server.It seems the url before "/" is the registry address and after "/" is the image name. and without "/" provided, docker-compose by default looks for the image from the remote docker.io.
It guess it's a known bug with docker-compose
I finally got it working by running the local registry, pushing the image to the local registry with the registry tag, and pulling the image from the local registry.
and then change the image url in the dockerfile:
Similarly for the chat-server image.
In your docker-compose.yml, you can specify
build: .
instead ofbuild: <username>/repo>
for local builds (rather than pulling from docker-hub) - I can't verify this yet, but I believe you may be able to do relative paths for multiple services to the docker-compose file.Reference: https://github.com/gvilarino/docker-workshop