Docker Compose up command times out frequently - docker

I am using Docker For Windows and have a set of images that are already built on my docker host. When I try to use the docker-compose up -d command to start my environment, I frequently face i/o timeout errors for different containers. Usually, retrying helps but I am trying to automate this and can't expect to re-run the whole pipeline.
Versions:
Docker version 18.09.0, build 4d60db4
docker-compose version 1.23.1, build b02f1306
Command line logs:
C:\workspace\AK_DOCKER_RISK\docker-compose>docker-compose up -d
Creating risk-svc ...
Creating risk-svc ... done
Creating risk-prc ...
Creating risk-web ...
Creating risk-web ... error
ERROR: for risk-web b'i/o timeout'
Creating risk-prc ... done
ERROR: for web b'i/o timeout'
Encountered errors while bringing up the project.
The error is observed randomly, sometimes for svc, or web or prc.
Can someone please explain why this error is occurring and more importantly - how to solve this issue?
This is my docker-compose.yml file:
version: '3'
services:
web:
image: iis-core-web:1910.252
build:
context: .
dockerfile: ./web/Dockerfile
container_name: risk-web
ports:
- "9111:8080"
tty: true
links:
- svc
volumes:
- ../RiskLogs/web:c:/RiskLogs
svc:
image: iis-core-svc:1910.252
build:
context: .
dockerfile: ./svc/Dockerfile
container_name: risk-svc
ports:
- "9112:8080"
tty: true
volumes:
- ../RiskLogs/svc:c:/RiskLogs
prc:
image: iis-core-prc:1910.252
build:
context: .
dockerfile: ./prc/Dockerfile
container_name: risk-prc
tty: true
links:
- svc
volumes:
- ../RiskLogs/prc:c:/RiskLogs
# prevent creation of new network and use existing nat
networks:
default:
external:
name: nat

Links is a legacy feature. Try user defined networks instead as per docs:
https://docs.docker.com/compose/compose-file/#links

Related

passing multiple .yml files to docker-compose

Docker noob here.
I have two files docker-compose.build.yml and docker-compose.up.yml in my docker folder. Following are the contents of both files..
docker-compose.build.yml
version: "3"
services:
base:
build:
context: ../
dockerfile: ./docker/Dockerfile.base
args:
DEBUG: "true"
image: ottertune-base
labels:
NAME: "ottertune-base"
web:
build:
context: ../
dockerfile: ./docker/Dockerfile.web
image: ottertune-web
depends_on:
- base
labels:
NAME: "ottertune-web"
volumes:
- ../server:/app
driver:
build:
context: ../
dockerfile: ./docker/Dockerfile.driver
image: ottertune-driver
depends_on:
- base
labels:
NAME: "ottertune-driver"
docker-compose.up.yml
version: "3"
services:
web:
image: ottertune-web
container_name: web
expose:
- "8000"
ports:
- "8000:8000"
links:
- backend
- rabbitmq
depends_on:
- backend
- rabbitmq
environment:
DEBUG: 'true'
ADMIN_PASSWORD: 'changeme'
BACKEND: 'postgresql'
DB_NAME: 'ottertune'
DB_USER: 'postgres'
DB_PASSWORD: 'ottertune'
DB_HOST: 'backend'
DB_PORT: '5432'
DB_OPTS: '{}'
MAX_DB_CONN_ATTEMPTS: 30
RABBITMQ_HOST: 'rabbitmq'
working_dir: /app/website
entrypoint: ./start.sh
labels:
NAME: "ottertune-web"
networks:
- ottertune-net
driver:
image: ottertune-driver
container_name: driver
depends_on:
- web
environment:
DEBUG: 'true'
working_dir: /app/driver
labels:
NAME: "ottertune-driver"
networks:
- ottertune-net
rabbitmq:
image: "rabbitmq:3-management"
container_name: rabbitmq
restart: always
hostname: "rabbitmq"
environment:
RABBITMQ_DEFAULT_USER: "guest"
RABBITMQ_DEFAULT_PASS: "guest"
RABBITMQ_DEFAULT_VHOST: "/"
expose:
- "15672"
- "5672"
ports:
- "15673:15672"
- "5673:5672"
labels:
NAME: "rabbitmq"
networks:
- ottertune-net
backend:
container_name: backend
restart: always
image: postgres:9.6
environment:
POSTGRES_USER: 'postgres'
POSTGRES_PASSWORD: 'ottertune'
POSTGRES_DB: 'ottertune'
expose:
- "5432"
ports:
- "5432:5432"
labels:
NAME: "ottertune-backend"
networks:
- ottertune-net
networks:
ottertune-net:
driver: bridge
Nothing wrong with the dockerfiles, i just have a few doubts about this approach.
What purpose does having multiple files serve instead of just one docker-compose.yml?
How does docker-compose work when used with multiple files?
When i do docker-compose -f docker-compose.build.yml build --no-cache
Building base
Step 1/1 : FROM ubuntu:18.04
---> 775349758637
[Warning] One or more build-args [DEBUG] were not consumed
Successfully built 775349758637
Successfully tagged ottertune-base:latest
Building web
Step 1/1 : FROM ottertune-base
---> 775349758637
Successfully built 775349758637
Successfully tagged ottertune-web:latest
Building driver
Step 1/1 : FROM ottertune-base
---> 775349758637
Successfully built 775349758637
Successfully tagged ottertune-driver:latest
and then docker-compose up i get the error
rabbitmq is up-to-date
backend is up-to-date Starting web ... error
ERROR: for web Cannot start service web: OCI runtime create failed: container_linux.go:346:
starting container process caused "exec: \"./start.sh\": stat ./start.sh: no such file or
directory": unknown
ERROR: for web Cannot start service web: OCI runtime create failed: container_linux.go:346:
starting container process caused "exec: \"./start.sh\": stat ./start.sh: no such file or
directory": unknown
ERROR: Encountered errors while bringing up the project.
this entrypoint start.sh is defined in the docker-compose.up.yml file which I didn't pass as an argument to
docker-compose build
So, why is the docker-compose up trying to run this entrypoint from a yml file which is not even passed during build? Really confused on this and didn't find much about it on google and stackoverflow.
If you docker-compose -f a.yml -f b.yml ..., Docker Compose merges the two YAML files. If you look at the two files you've posted, one has all of the run-time settings (ports:, environment:, ...), and if you happened to have the images already it would be enough to run the application. The second only has build-time settings (build:), but requires the source tree checked out locally to be able to run.
You probably need to specify both files on every docker-compose invocation
docker-compose -f docker-compose.build.yml -f docker-compose.up.yml up --build
It does seem like the author of these files intended for them to be run separately
docker-compose -f docker-compose.build.yml build
docker-compose -f docker-compose.up.yml up
but note that some of the run-time options in the build file, like volumes: to hide the application built into the image, will never take effect.
(You should be able to delete a large number of settings in the "up" YAML file that either duplicate what's in the image or that Docker Compose can provide for you: container_name:, expose:, links:, working_dir:, entrypoint:, networks:, and (probably) labels: are all unnecessary and can be deleted.)
What purpose does having multiple files serve instead of just one docker-compose.yml?
You can share configuration across environments. For example, I keep the common configuration such as the network and server in a docker-compose.yml. I keep my development environment specifics such as a server with automatic reload and debugging enabled in a docker-compose.override.yml. I keep the production-specific configs in a docker-compose.prod.yml. Then I can run docker-compose up --build for my development environment (Docker Compose uses docker-compose.yml and docker-compose.override.yml by default). And I can run my prod environment with docker-compose -f docker-compose.yml -f docker-compose.prod.yml up --build. You can read about this in the dedicated docs page.
How does docker-compose work when used with multiple files?
It takes the first file as the base file, and adds or replaces configs from subsequent files ot the base file. See the relevant docs.
When i do docker-compose -f docker-compose.build.yml build --no-cache ...
As for your last question, I can't really tell by what I've seen. But unlike Dockerfiles which need two commands (docker build and docker run), docker-compose only needs one. So when you do docker-compose up, it looks for a file named docker-compose.yml (and also docker-compose.override.yml if it's present).

Pycharm remote interpreter using docker-compose not working in debug mode

I have a Pycharm remote interpreter setup using docker-compose, I am able to run the project fine but when trying to debug I am getting this error:
ERROR: for e21cea317159_my_proj Cannot create container for service myproj: conflicting options: port publishing and the container type network mode
My docker-compose file:
version: '1.0'
services:
my-router:
image: testimage:latest
dns: 10.10.10.10
dns_search:
- testwebsite.com
et:
build:
context: ""
dockerfile: Dockerfile
volumes:
- .:/workarea
depends_on:
- "my-router"
environment:
- WAIT_FOR_PORTS=my-router:12345
network_mode: service:my-router
Thanks for the help!

` docker-compose up ` invalid service name '.....' - only [a-zA-Z0-9\._\-] characters are allowed

I have a local docker image which has name img_test. My docker-compose.yml file is:
version: '2'
services:
img_test:
image: img_test:latest
ports:
- "8080:80"
mysql:
image: mysql:latest
ports:
- "3636:3036"
nvidia/cuda:
image: nvidia/cuda:latest
runtime: nvidia
command: nvidia-smi
networks:
appnet:
external: true
I also have Dockerfile . When I run the command docker-compose up It throws this error.
ERROR: The Compose file './docker-compose.yml' is invalid because:
Invalid service name 'img_test' - only [a-zA-Z0-9\._\-] characters are allowed
I gave another names such as img/test, imgtest but they did not work.
I also tried build the Dockerfile in docker-compose.yml file by this command.
version: '2'
services:
app:
build: .
It gives same error for app.
What is the solution? I am new on Docker. I tested my image and it is working correctly. I dont want to push my image to Dockerhub. Is there another way to solve this problem?
It's a relatively old version of docker-compose. They had this bug in the past. Try upgrading.
https://github.com/docker/compose/issues/4754

Docker Compose: Volumes not working on Windows Nano

I've got two Windows Nano docker containers ... one with a service on, the second with my Automated Acceptance Tests.
I'm trying to add a volume to the aat container so I can copy off the tests output.
I've seen elsewhere I'm supposed to use ...
COMPOSE_CONVERT_WINDOWS_PATHS=1
But can't seem to get anywhere :S
version: '3.3'
services:
fancyservice:
restart: always
image: fancyservice
aat-runner:
environment:
- FancyServiceUrl=http://fancyservice/
- COMPOSE_CONVERT_WINDOWS_PATHS=1
volumes:
- .:/output:rw
restart: always
image: aat-runner
I get:
ERROR: for aat_aat-runner_1 Cannot create container for service aat-runner: invalid volume spec "/output"
ERROR: for aat-runner Cannot create container for service aat-runner: invalid volume spec "/output": invalid volume specification: '\output'
ERROR: Encountered errors while bringing up the project.
You have to specify the volume at the same level as "services:" as well as against the individual container ...
version: '3.3'
services:
fancyservice:
restart: always
image: fancyservice
aat-runner:
environment:
- FancyServiceUrl=http://fancyservice/
- COMPOSE_CONVERT_WINDOWS_PATHS=1
volumes:
- .:/output:rw
restart: always
image: aat-runner
volumes:
- aat-output:c:\aat-output\
volumes:
aat-output:

Use Docker Compose to create multiple containers

I am completely new to Docker. I have a sonarqube image. I wrote a sample Docker Compose file and ran the image. Everything is working fine. Now I want to create 5-6 containers using Docker Compose.
How can I do this?
This is my sample YAML file:
version: '2'
services:
web:
build: .
ports:
- "9000:9000"
depends_on:
- my_image
my_image:
image: mySonarApp
I also would be interested in knowing if it is possible to create them only with my docker config file.
Just add more service definitions
version: '2'
services:
weba:
build: .
ports:
- "9000:9000"
weba:
build: .
ports:
- "9001:9000"
webc:
build: .
ports:
- "9002:9000"
You can use the scale command to create more instances of the service:
docker-compose scale web=6

Resources