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
Related
My goal: generate docker-compose.yaml from docker-compose.yaml and docker-compose.override.yaml and keep the variables as they are now = without interpolate
I've tried to run
docker compose -f docker-compose.yaml -f docker-compose.override.yaml convert --no-interpolate > new-docker-compose.yaml
Here is my docker-compose.yaml:
version: "3.5"
services:
redis-db:
image: redislabs/rejson:2.0.11
container_name: redis-db
restart: unless-stopped
volumes:
- redis-storage-vol:/data
- ${PWD}/config/redis/redis.conf:/usr/local/etc/redis/redis.conf:ro
ports:
- 6379:6379
runner:
image: "${REPO}/runner/${RUNNER_CPU_IMAGE}:${RUNNER_CPU_TAG}"
container_name: runner
restart: unless-stopped
volumes:
- data-storage-vol:/data
- ${PWD}/config/runner/runner-configuration.ini:/configuration.ini:ro
- "${PWD}/solutions/${ALGO}:/home/scripts/algorithmic_solutions_list.txt:ro"
depends_on:
- "redis-db"
gateway:
image: "${REPO}/gateway/gateway-server:${GATEWAY_TAG}"
container_name: gateway
restart: unless-stopped
volumes:
- data-storage-vol:/data
- ${PWD}/config/gateway/gateway-configuration.ini:/configuration.ini:ro
ports:
- 8000:8000
depends_on:
- "redis-db"
volumes:
data-storage-vol:
driver_opts:
type: "tmpfs"
device: "tmpfs"
o: "size=5g,uid=1000"
redis-storage-vol:
driver: local
docker-compose.override.yaml
version: "3.5"
services:
runner:
image: "${REPO}/runner/${RUNNER_GPU_IMAGE}:${RUNNER_GPU_TAG}"
deploy:
resources:
reservations:
devices:
- driver: nvidia
capabilities: [ GPU ]
What I've tried:
Run docker compose convert without flag --no-interpolate, it worked well but the variables was populated.
Run like the example - but got this error:
service "gateway" refers to undefined volume ${PWD}/config/gateway/gateway-configuration.ini: invalid compose project
I want to keep using docker compose commands and not edit files after its created.
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
I am trying to get a couple of containers up and running, however I am running into some issues. I run this command:
docker-compose up -d --build itvdflab
and get this error
The Compose file './docker-compose.yaml' is invalid because:
Unsupported config option for services: 'itvdelab'
Unsupported config option for networks: 'itvdelabnw'
Here is the yaml file.
services:
itvdelab:
image: itversity/itvdelab
hostname: itvdelab
ports:
- "8888:8888"
volumes:
- "./itversity-material:/home/itversity/itversity-material"
- "./data:/data"
environment:
SHELL: /bin/bash
networks:
- itvdelabnw
depends_on:
- "cluster_util_db"
cluster_util_db:
image: postgres:13
ports:
- "6432:5432"
volumes:
- ./cluster_util_db_scripts:/docker-entrypoint-initdb.d
networks:
- itvdelabnw
environment:
POSTGRES_PASSWORD: itversity
itvdflab:
build:
context: .
dockerfile: images/pythonsql/Dockerfile
hostname: itvdflab
ports:
- "8888:8888"
volumes:
- "./itversity-material:/home/itversity/itversity-material"
- "./data:/data"
environment:
SHELL: /bin/bash
networks:
- itvdelabnw
depends_on:
- "pg.itversity.com"
pg.itversity.com:
image: postgres:13
ports:
- "5432:5432"
networks:
- itvdelabnw
environment:
POSTGRES_PASSWORD: itversity
networks:
itvdelabnw:
name: itvdelabnw
What changes do I need to make to get this working?
Your docker-compose.yml file is missing a version: line. Until very recently, this caused Docker Compose to interpret this as the original "version 1" Compose format, which doesn't have a top-level services: key and doesn't support Docker networks. The much newer Compose Specification claims that a version: key is optional, but in practice if you can't be guaranteed to use a very new version of Compose (built as a plugin to the docker binary) it's required. The most recent Compose file versions supported by the standalone Python docker-compose tool are 3.8 and 2.4 (you need the 2.x version for some resource-related constraints in non-Swarm installations).
# Add at the very beginning
version: '3.8'
Here is the revised copy:
version: '3.4'
services:
itvdelab:
image: itversity/itvdelab
hostname: itvdelab
ports:
- "8888:8888"
volumes:
- "./itversity-material:/home/itversity/itversity-material"
- "./data:/data"
environment:
SHELL: /bin/bash
networks:
- itvdelabnw
depends_on:
- "cluster_util_db"
cluster_util_db:
image: postgres:13
ports:
- "6432:5432"
volumes:
- ./cluster_util_db_scripts:/docker-entrypoint-initdb.d
networks:
- itvdelabnw
environment:
POSTGRES_PASSWORD: itversity
itvdflab:
build:
context: .
dockerfile: images/pythonsql/Dockerfile
hostname: itvdflab
ports:
- "8888:8888"
volumes:
- "./itversity-material:/home/itversity/itversity-material"
- "./data:/data"
environment:
SHELL: /bin/bash
networks:
- itvdelabnw
depends_on:
- "pg.itversity.com"
pg.itversity.com:
image: postgres:13
ports:
- "5432:5432"
networks:
- itvdelabnw
environment:
POSTGRES_PASSWORD: itversity
networks:
itvdelabnw:
name: itvdelabnw
and now I get the following error
ERROR: The Compose file './docker-compose.yaml' is invalid because:
services.pg.itversity.com.networks.itvdelabnw contains unsupported option: 'name'
for me work try different version. In my case work
version: '2.2'
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?
I have a docker-compose which looks like:
version: '3.2'
services:
jobsaf-server:
build:
context: ./application
dockerfile: Dockerfile.production
container_name: jobsaf-server
env_file:
- ./application/.env
tty: true
depends_on:
- "redis"
- "mongo"
links:
- mongo
- redis
volumes:
- ./application/server:/var/www/app/jobsaf-website/server
- ./application/public/assets:/var/www/app/jobsaf-website/public/assets
- ./application/uploads:/var/www/app/jobsaf-website/uploads
- ./application/sitemaps:/var/www/app/jobsaf-website/sitemaps
- ./application/rss:/var/www/app/jobsaf-website/rss
- "/etc/timezone:/etc/timezone:ro"
- "/etc/localtime:/etc/localtime:ro"
nginx:
image: nginx:stable
tty: true
env_file:
- ./.env
environment:
- NGINX_HOST=${APP_HOST}
- NGINX_PORT=${APP_PORT}
- PUID=1001
- PGID=1001
- TZ=Asia/Kabul
links:
- jobsaf-server
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
- ./nginx/ssl/star_jobs_af.pem:/etc/ssl/star_jobs_af.pem
- ./nginx/ssl/jobs.af.key:/etc/ssl/jobs.af.key
- ./nginx/ssl/star_jobs_af.crt:/etc/ssl/star_jobs_af.crt
ports:
- "80:80"
- "443:443"
mongo:
image: mongo:latest
container_name: mongo
tty: true
env_file:
- ./.env
volumes:
- "db-data:/data/db"
environment:
- MONGO_INITDB_ROOT_USERNAME=${DB_USER}
- MONGO_INITDB_ROOT_PASSWORD=${DB_PASS}
- MONGO_INITDB_DATABASE=admin
ports:
- "0.0.0.0:27017:27017"
redis:
image: redis
container_name: redis
tty: true
volumes:
db-data:
# - /data/db
networks:
front-tier:
back-tier:
It build jobsaf-server:latest by default.
what I want is to keep the old tag and build the new one.
let say, while building the images I should pass something similar to this
docker-compose -f docker-compose.production --tag=1.0.1
the above command should build for me and image with tag jobsaf-server:1.0.1
Is it really possible to have such result?
Or is there any alternative solution for it
Thanks in advance.
Note: I want to keep the old image, in case if my new image has issue, then I can use the old image.
version: '3.2'
services:
jobsaf-server:
image: jobsaf-server:${TAG}
build:
context: ./application
dockerfile: Dockerfile.production
...
The best way to supply the tag is with a .env file like this:
TAG=1.0.1
Docker-compose will pick this up automatically.
From #Mihai suggestion following steps worked for me, incase if someone else needed.
version: '3.2'
services:
jobsaf-server:
image: jobsaf-server:${TAG}
build:
context: ./application
dockerfile: Dockerfile.production
To build:
Run TAG=1.0 docker-compose build it will create jobsaf-server:1.0
To Up:
Run TAG=1.0 docker-compose up -d
To down:
Run TAG=1.0 docker-compose down
Note: we can add TAG to .env file also by default.