I need my container (local grpc_alpine) to have internet access whilst connected to a internal network. I have tried the following yaml file:
version: '2'
services:
gr1:
image: grpc_alpine
hostname: gr1
container_name: gr1
privileged: true
stdin_open: true
tty: true
volumes:
- "${PWD}/assets/grpc:/etc/grpc"
networks:
- default
- mynet:
ipv4_address: "10.10.10.11"
environment:
- DEFAULT_GATEWAY=10.10.10.254
networks:
mynet:
ipam:
config:
- subnet: 10.10.10.0/24
gateway: 10.10.10.254
but throws this issue:
compose.config.config.find: Using configuration files:
./docker-compose.yml ERROR: compose.cli.main.main: The Compose file
'./docker-compose.yml' is invalid because: services.gr1.networks
contains {"mynet": {"ipv4_address": "10.10.10.11"}}, which is an
invalid type, it should be a string
There's a small issue with your yaml configuration. The networks option in services expects a map rather than a list. Try this:
version: '2'
services:
gr1:
image: grpc_alpine
hostname: gr1
container_name: gr1
privileged: true
stdin_open: true
tty: true
volumes:
- "${PWD}/assets/grpc:/etc/grpc"
networks:
default:
mynet:
ipv4_address: "10.10.10.11"
environment:
- DEFAULT_GATEWAY=10.10.10.254
networks:
mynet:
ipam:
config:
- subnet: 10.10.10.0/24
gateway: 10.10.10.254
Related
I am getting following error
version: '3.9'
services:
app-1:
container_name: app-1
image: app/app:1.0.0
networks:
app_network:
- ipv4_address: 192.28.0.2
app-2:
container_name: app-2
image: app/app:1.0.0
networks:
app_network:
- ipv4_address: 192.28.0.3
app-3:
container_name: app-3
image: app/app:1.0.0
networks:
app_network:
- ipv4_address: 192.28.0.4
networks:
app_network:
driver: default
ipam:
driver: default
config:
- subnet: 192.28.0.0/16
gateway: 192.28.0.1
Getting following error
docker-compose up -d
ERROR: The Compose file './docker-compose.yaml' is invalid because:
services.app-1.networks.app_network contains an invalid type, it should be an object, or a null
services.app-2.networks.app_network contains an invalid type, it should be an object, or a null
services.app-3.networks.app_network contains an invalid type, it should be an object, or a null
the problem is on your app_network section, can you try with?
version: '3.9'
services:
app-1:
container_name: app-1
image: app/app:1.0.0
networks:
app_network:
ipv4_address: 192.28.0.2 #without -
app-2:
container_name: app-2
image: app/app:1.0.0
networks:
app_network:
ipv4_address: 192.28.0.3 #without -
app-3:
container_name: app-3
image: app/app:1.0.0
networks:
app_network:
ipv4_address: 192.28.0.4 #without -
networks:
app_network:
driver: default
ipam:
driver: default
config:
- subnet: 192.28.0.0/16
gateway: 192.28.0.1
How do I fix the docker-compose.yml? expected , but found ''
ERROR: yaml.parser.ParserError:
while parsing a block collection
in "testnode.yml", line 11, column 7
expected <block end>, but found '<scalar>'
in "testnode.yml", line 11, column 18
How can I fix this?
version: '3'
services:
uip-dns:
container_name: uip-dns
working_dir: /build
image: "alpine"
ports:
- "26668:26668"
volumes:
- {{build}}:/build:Z
command: ./dns
networks:
nsb_net:
ipv4_address: 192.167.233.2
node:
container_name: node
image: "tendermint-nsb/node"
ports:
- "26656-26657:26656-26657"
environment:
- PORT=:27667
- DB_DIR=./data100/
- TCP_AD=tcp://0.0.0.0:27667
- ID=100
- LOG=${LOG:-tendermint.log}
- UIP_CHAIN_DNS=http://uip-dns:26668
volumes:
- {{build}}:/tendermint:Z
command: node --rpc.laddr=tcp://0.0.0.0:26657 --proxy_app=tcp://0.0.0.0:27667
networks:
nsb_net:
ipv4_address: 192.167.233.233
networks:
nsb_net:
# external: true
driver: bridge
ipam:
driver: default
config:
-
subnet: 192.167.232.0/22
The {{build}} is not valid for docker-compose.yml. That looks like a golang template that would normally be expanded before passing the file to docker-compose. You'll want to replace that with a string, or defined variable. E.g.
version: '3'
services:
uip-dns:
container_name: uip-dns
working_dir: /build
image: "alpine"
ports:
- "26668:26668"
volumes:
- ${build_dir:-./build}:/build:Z
command: ./dns
networks:
nsb_net:
ipv4_address: 192.167.233.2
node:
container_name: node
image: "tendermint-nsb/node"
ports:
- "26656-26657:26656-26657"
environment:
- PORT=:27667
- DB_DIR=./data100/
- TCP_AD=tcp://0.0.0.0:27667
- ID=100
- LOG=${LOG:-tendermint.log}
- UIP_CHAIN_DNS=http://uip-dns:26668
volumes:
- ${build_dir:-./build}:/tendermint:Z
command: node --rpc.laddr=tcp://0.0.0.0:26657 --proxy_app=tcp://0.0.0.0:27667
networks:
nsb_net:
ipv4_address: 192.167.233.233
networks:
nsb_net:
# external: true
driver: bridge
ipam:
driver: default
config:
- subnet: 192.167.232.0/22
I also strongly recommend getting rid of all the fixed IP's for the subnet and containers. Those break portability, and the ability to scale, rolling update, and various other features. Use the published port and host IP address instead, or docker's DNS between containers, if at all possible (reference).
I am trying to install gitlab ce with docker compose file. I have had lots of permissions problem with bind volumes. I would like to try names volumes. Following is my file.
web:
image: 'gitlab/gitlab-ce:latest'
container_name: 'gitlab'
restart: always
hostname: 'gitlab.xxxx.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://gitlab.xxxx.com'
ports:
- '10080:80'
- '10443:443'
- '10022:22'
volumes:
- gitlab_config:/etc/gitlab
- gitlab_log:/var/log/gitlab
- gitlab_data:/var/opt/gitlab
volumes:
gitlab_config:
external: true
gitlab_log:
external: true
gitlab_data:
external: true
I receive following error:
docker-compose up -d
ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for volumes: 'gitlab_data'
Volumes have been created previously with docker volume create command
UPDATE : Based the solution by Ganesh Satpute, I submit the working/tested file below. Someone may need it since gitlab page does not provide it. Thank you "Ganesh".
---
version: "2.4"
services:
web:
image: 'gitlab/gitlab-ce:latest'
container_name: 'gitlab'
restart: always
hostname: 'gitlab.xxxx.com'
environment:
GITLAB_OMNIBUS_CONFIG: 'https://gitlab.xxxx.com'
ports:
- '10080:80'
- '10443:443'
- '10022:22'
volumes:
- gitlab_config:/etc/gitlab
- gitlab_log:/var/log/gitlab
- gitlab_data:/var/opt/gitlab
volumes:
gitlab_config:
external: true
gitlab_log:
external: true
gitlab_data:
external: true
I modified your docker-compose.yml with this
version: "2.4"
services:
web:
image: 'gitlab/gitlab-ce:latest'
container_name: 'gitlab'
restart: always
hostname: 'gitlab.xxxx.com'
environment:
GITLAB_OMNIBUS_CONFIG: 'https://gitlab.xxxx.com'
ports:
- '10080:80'
- '10443:443'
- '10022:22'
volumes:
- gitlab_config:/etc/gitlab
- gitlab_log:/var/log/gitlab
- gitlab_data:/var/opt/gitlab
volumes:
gitlab_config:
external: true
gitlab_log:
external: true
gitlab_data:
external: true
You can always check by running docker-compose config to check if the config file is valid or not. If not google the errors and also check few examples online.
I am trying to set a static IP on my docker-compose v3 file but.. i can't.
Each time I set it, I can't connect to the webpage anymore.
I am getting ERR_ADDRESS_UNREACHABLE
Here is my config:
# docker-compose.yml
version: '3'
services:
web:
build: ./etc/nginx
ports:
- "90:80"
volumes:
- "./etc/ssl:/etc/ssl"
depends_on:
- php
- database
php:
build: ./etc/php
ports:
- 9000:9000
links:
- database:mysqldb
volumes:
- "./etc/php/php.ini:/usr/local/etc/php/conf.d/php.ini"
- ${APP_PATH}:/var/www/symfony
database:
image: mysql
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
ports:
- 3300:3306
volumes:
- "./data/db/mysql:/var/lib/mysql"
and
# docker-compose.override.yml
version: '3'
services:
web:
networks:
test:
ipv4_address: '10.1.0.100'
networks:
test:
ipam:
driver: default
config:
- subnet: 10.1.0.0/24
It should be like this:
services:
web:
networks:
test:
ipv4_address: 10.1.0.100
networks:
test:
driver: bridge
ipam:
driver: default
config:
- subnet: 10.1.0.0/24
And in my case I placed networks section before services.
UPDATE:
eventually I've ended up using external network for like this:
docker network create --subnet 10.5.0.0/24 local_network_dev
and then in any docker-compose you can just use it like this:
version: '3.2'
networks:
default:
external:
name: local_network_dev
and inside of image:
web:
networks:
default:
ipv4_address: 10.5.0.11
# Use root/example as user/password credentials
version: '3.3'
networks:
netBackEnd:
ipam:
driver: default
config:
- subnet: 192.168.0.0/24
services:
mongo-db:
image: mongo
container_name: cnt_mongo
restart: always
environment:
MONGO_INITDB_DATABASE: dbArland
MONGO_INITDB_ROOT_USERNAME: maguilarac
MONGO_INITDB_ROOT_PASSWORD: pwdmaguilarac
ports:
- 27017:27017
volumes:
- ./script1_creacion_usuario.js:/docker-entrypoint-initdb.d/script1_creacion_usuario.js:ro
- ./script2_creacion_coleccion.js:/docker-entrypoint-initdb.d/script2_creacion_coleccion.js:ro
- ./script4_carga_productos.js:/docker-entrypoint-initdb.d/script4_carga_productos.js:ro
- ./productos_inicial.json:/docker-entrypoint-initdb.d/productos_inicial.json:ro
- ./mongo-volume:/data/db
networks:
netBackEnd:
ipv4_address: 192.168.0.4
mongo-express:
image: mongo-express
container_name: cnt_mongo-express
restart: always
ports:
- 9081:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: maguilarac
ME_CONFIG_MONGODB_ADMINPASSWORD: pwdmaguilarac
networks:
netBackEnd:
ipv4_address: 192.168.0.6
Just a very important note that should all future users know.
If you are trying to edit already existing network, you will most likely get error
Cannot start service xxx: Invalid address xxx.xxx.xxx.xxx: It does not belong to any of this network's subnets
I have been struggling for about 2 hours with this problem. The solution is to set a different name for the network or propably use docker-compose down.
Networks settings is not much different between versions 2 and 3, but here is a good link to official doc (v3): https://docs.docker.com/compose/compose-file/compose-file-v3/#ipv4_address-ipv6_address
I have the docker-compose.yml file
web_server:
build: web_server/
ports:
- "8000:8000"
links:
- mongo
tty: true
environment:
SYMFONY__MONGO_ADDRESS: mongo
SYMFONY__MONGO_PORT: 27017
networks:
app_net:
ipv4_address: 172.16.238.10
ipv6_address: 2001:3984:3989::10
networks:
app_net:
driver: bridge
enable_ipv6: true
ipam:
driver: default
config:
-
subnet: 172.16.238.0/24
-
subnet: 2001:3984:3989::/64
mongo:
image: mongo:3.0
container_name: mongo
command: mongod --smallfiles
expose:
- 27017
I want to have a specifiy IP for my web_server for pass this in another applications.
But when I call command docker-compose up I recive the error:
ERROR: The Compose file '.\docker-compose.yml' is invalid because:
Unsupported config option for networks: 'app_net'
Unsupported config option for web_server: 'networks'
What is wrong?
I dont't known why you have this error but you can try to fix some points:
webserver networks must refer the networks declared below
you simplify your network configuration and start with ipv4 only
Here is a working configuration:
version: '2'
services:
webssl:
image: nginx:1.11.4-alpine
ports:
- "443:443"
- "80:80"
volumes:
- /data/nginx/webroot:/usr/share/nginx/html:ro
networks:
- dmz
networks:
dmz:
ipam:
driver: default
config:
- subnet: 172.77.0.1/24
ip_range: 172.77.0.0/24
gateway: 172.77.0.1