Docker "Builder_container" exit before docker "Gather_container" process finished - docker

I have two docker containers, when docker "builder_container" must wait for docker "Gather_container" to finish the process before starting.
Here is what the Docker-compose file looks like:
version: '3'
services:
Gather:
build:
dockerfile: ./Gather/Dockerfile
container_name: gather_container
image: gather_img
volumes:
- ./Gather:/app/
Builder:
build:
dockerfile: ./Builder/Dockerfile
container_name: builder_container
image: builder_img
volumes:
- ./Builder:/app/
depends_on:
- Gather

Related

Docker Compose not reading multiple files

Using the below docker compose files, i am unable to bring up my app correctly. Docker says my LAPIS_ENV environment variable is not set, but i am setting it in my second compose file which I am expecting to be merged into the first one. I have tried including them in reverse order to no avail.
version: '2.4'
services:
backend:
mem_limit: 50mb
memswap_limit: 50mb
build:
context: ./backend
dockerfile: Dockerfile
depends_on:
- postgres
volumes:
- ./backend:/var/www
- ./data:/var/data
restart: unless-stopped
command: bash -c "/usr/local/bin/docker-entrypoint.sh ${LAPIS_ENV}"
postgres:
build:
context: ./postgres
dockerfile: Dockerfile
environment:
PGDATA: /var/lib/postgresql/data/pgdata
POSTGRES_HOST_AUTH_METHOD: trust
volumes:
- postgres:/var/lib/postgresql/data
- ./postgres/pg_hba.conf:/var/lib/postgres/data/pg_hba.conf
- ./data/backup:/pgbackup
restart: unless-stopped
volumes:
postgres:
version: '2.4'
services:
backend:
environment:
LAPIS_ENV: development
ports:
- 8080:80
#!/usr/bin/env bash
docker compose -f docker-compose.yml -f docker-compose.dev.yml up

Docker Compose ports are being ignored on up

This is my Docker Compose file containing 4 api containers:
version: '3.4'
services:
api1.api:
image: ${DOCKER_REGISTRY-}api1
build:
context: .
dockerfile: Api1.Api/Dockerfile
networks:
- dev-network
ports:
- "62000:443"
- "62001:80"
api2.api:
image: ${DOCKER_REGISTRY-}api2
build:
context: .
dockerfile: Api2.Api/Dockerfile
networks:
- dev-network
ports:
- "62002:443"
- "62003:80"
api3.api:
image: ${DOCKER_REGISTRY-}api3
build:
context: .
dockerfile: Api3.Api/Dockerfile
networks:
- dev-network
ports:
- "62004:443"
- "62005:80"
api4.api:
image: ${DOCKER_REGISTRY-}api4
build:
context: .
dockerfile: Api4.Api/Dockerfile
networks:
- dev-network
ports:
- "62006:443"
- "62007:80"
networks:
dev-network:
name: dev-network
I have set the ports but when I run docker-compose up -d, the results are that either 1 or 2 of the apis will have the specified ports only. The rest will be randomly generated or even blank.
I have to manually restart that container before it generates a random port.
Am I missing a command or step? How can I get my docker-compose to follow the ports that have been set?

Gitlab CI shell runner fails with docker-compose up

I'm trying to start multiple docker containers with a wsl shell runner. After running
compose_job:
tags:
- wsl
stage: compose
script:
- cd /pathToComposeFile
- docker-compose up
dependencies:
- pull_job
the runner excited with following error:
$ docker-compose up
docker: invalid reference format: repository name must be lowercase.
the docker-compose.yml is:
version: '3'
services:
cron:
build: cron/.
container_name: cron
image: cron_image
ports:
- 6040:6040
The referenced images are all written in lowercase and the same command excited as expected
if run manually. I already checked that docker-compose is accessible and that the docker-compose.yml is readable. How can I resolve this issue? Thank you in advance!
I think service_name, container_name and env must be lowercase.
Look like
version: '3'
services:
perihubapi:
build:
context: api/.
args:
EXTERNAL: ${external}
FASERVICES: ${faservices}
container_name: perihubapi
image: peri_hub_api_image
ports:
- 6020:6020
networks:
- backend
volumes:
- peridigm_volume:/app/peridigmJobs
- paraView_volume:/app/paraView
- secrets:/app/certs
perihubgui:
build: gui/.
container_name: perihubgui
image: peri_hub_gui_image
ports:
- 6010:6010
networks:
- backend
volumes:
- secrets:/app/certs
peridigm:
build:
context: peridigm/.
args:
GITLAB_USER: ${gitlab_user}
GITLAB_TOKEN: ${gitlab_token}
PERIDOX: ${peridox}
container_name: peridigm
image: peridigm_image
ports:
- 6030:6030
networks:
- backend
volumes:
- peridigm_volume:/app/peridigmJobs
paraview:
build:
context: paraview/.
container_name: paraview
image: paraview_image
volumes:
- paraView_volume:/app/paraView
cron:
build: cron/.
container_name: cron
image: cron_image
ports:
- 6040:6040
networks:
- backend
networks:
backend:
driver: bridge
volumes:
peridigm_volume:
paraView_volume:
secrets:
external: true

Can i run cmd command in docker compose outside of container?

I have 2 docker-compose files that build a dockerfile, and i want join those docker-compose files
so, i created other docker-compose that goes up these 2 images
version: "3.4"
services:
frontend:
image: frontend-image
depends_on:
- backend
ports:
- "3000:80"
networks:
- teste-network
backend:
image: backend-image
ports:
- "5001:80"
networks:
- test-network
networks:
test-network:
driver: bridge
but, this docker-compose file not build the images
then i created a bash command that build these images
bash -c "docker-compose -f ./frontend/docker/docker-compose.yml build
&& docker-compose -f ./backend/docker/docker-compose.yml build"
I want to run this script before up containers, just typing docker-compose up
i assume that you have 2 dockerfiles - one for the frontend and the other for the backend, where each of which resides in the corresponding folder from your post, that is:
frontend/docker/Dockerfile
backend/docker/Dockerfile
then you can leverage docker-compose to build and run your images. all you have to do is to tell docker-compose where are the dockerfiles, which you can do by utilizing the build configuration.
version: "3.4"
services:
frontend:
image: frontend-image
build: ./frontend/docker
depends_on:
- backend
ports:
- "3000:80"
networks:
- test-network
backend:
image: backend-image
build: ./backend/docker
ports:
- "5001:80"
networks:
- test-network
networks:
test-network:
driver: bridge
then running docker-compose up frontend will build the docker images (if they do no exist), and then start them.

How to use single docker compose to build containers in different directories

I want to spin up two containers when I do docker-compose up
I have two folders API and front. Each has a Dockerfile and docker-compose file. currently, I have to do docker-compose up for each app.
like below
- api
- docker-compose.yml
- Dockerfile
- front
- docker-compose.yml
- Dockerfile
I want to have one docker-compose.yml to manage two containers like below.
- docker-compose.yml
- api
- Dockerfile
- front
- Dockerfile
api docker-compose
version: '3'
services:
api:
build: .
command: pipenv run start
image : data-tracker-backend
volumes:
- .:/api/
ports:
- "8000:8000"
front docker-compose
version: '3'
services:
web:
build: .
command: npm start
image : data-tracker-front
volumes:
- .:/front/
ports:
- "5000:5000"
I want to have something like
version: '3'
services:
api:
build: .
command: pipenv run start
image : data-tracker-backend
volumes:
- .:/api/
ports:
- "8000:8000"
front:
build: .
command: npm start
image : data-tracker-front
volumes:
- .:/front/
ports:
- "5000:5000"
help to access the command from the different working directories.
You can change the build directory and the volumes one.
version: '3'
services:
api:
build: ./api
volumes:
- ./api:/api
# the rest of your commands...
front:
build: ./front
volumes:
- ./front:/front
# the rest of your commands...
My suggestion though is to read the guidelines. It's plenty of information and tutorials there.
You can try to use build context and dockerfile as shown below
- docker-compose.yml
- api
- Dockerfile
- front
- Dockerfile
version: '3'
services:
api:
build:
context: api
dockerfile: Dockerfile
command: pipenv run start
image : data-tracker-backend
volumes:
- .:/api/
ports:
- "8000:8000"
front:
build:
context: front
dockerfile: Dockerfile
command: npm start
image : data-tracker-front
volumes:
- .:/front/
ports:
- "5000:5000"

Resources