Closed mm86133 closed 2 years ago
Please use compose v2. Not the old compose v1. This is not a bug. Closing. Feel free to reopen if this stays even after using compose v2.
I enabled docker compose v2 in Docker and still get this error when running docker-compose up -d. I am using Mac, so not sure if that is a factor.
docker-compose
is still v1. Notice the dash. Use docker compose
- with v2, compose is a docker subcommand, not a separate one.
docker-compose
is still v1. Notice the dash. Usedocker compose
- with v2, compose is a docker subcommand, not a separate one.
Thank you for your help. However, removing the dash creates the same error message listed in this issue.
Share your compose file (as it is exactly without the sensitive stuff if any)
Run docker compose config
in the same directory as the compose file. Share the output here. Again removing any sensitive data.
Share your compose file (as it is exactly without the sensitive stuff if any)
Run
docker compose config
in the same directory as the compose file. Share the output here. Again removing any sensitive data.
Thank you for following up so quickly! I was able to get it working by replacing:
"${MONGO_URL:-\ mongodb://${MONGODB_ADVERTISED_HOSTNAME:-mongodb}:${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}/\ ${MONGODB_DATABASE:-rocketchat}?replicaSet=${MONGODB_REPLICA_SET_NAME:-rs0}}"
with:
MONGO_URL: ${MONGO_URL:-mongodb://mongodb:27017/rocketchat?replicaSet=rs0}
I ran the docker compose exactly as it is in the example except the rocketchat version is 5.0.6
instead of latest
.
Here is my compose file that triggers the error:
volumes:
mongodb_data: { driver: local }
services:
rocketchat:
image: registry.rocket.chat/rocketchat/rocket.chat:${RELEASE:-5.0.6}
restart: on-failure
labels:
traefik.enable: "true"
traefik.http.routers.rocketchat.tls: "true"
traefik.http.routers.rocketchat.entrypoints: https
traefik.http.routers.rocketchat.tls.certresolver: le
environment:
MONGO_URL: "${MONGO_URL:-\
mongodb://${MONGODB_ADVERTISED_HOSTNAME:-mongodb}:${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}/\
${MONGODB_DATABASE:-rocketchat}?replicaSet=${MONGODB_REPLICA_SET_NAME:-rs0}}"
MONGO_OPLOG_URL: "${MONGO_OPLOG_URL:\
-mongodb://mongodb:${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}/\
local?replicaSet=${MONGODB_REPLICA_SET_NAME:-rs0}}"
ROOT_URL: ${ROOT_URL:-http://localhost:${HOST_PORT:-3000}}
PORT: ${PORT:-3000}
DEPLOY_METHOD: docker
depends_on:
- mongodb
expose:
- ${PORT:-3000}
ports:
- "${BIND_IP:-0.0.0.0}:${HOST_PORT:-3000}:${PORT:-3000}"
mongodb:
image: docker.io/bitnami/mongodb:${MONGODB_VERSION:-4.4}
restart: on-failure
volumes:
- mongodb_data:/bitnami/mongodb
environment:
MONGODB_REPLICA_SET_MODE: primary
MONGODB_REPLICA_SET_NAME: ${MONGODB_REPLICA_SET_NAME:-rs0}
MONGODB_PORT_NUMBER: ${MONGODB_PORT_NUMBER:-27017}
MONGODB_INITIAL_PRIMARY_HOST: ${MONGODB_INITIAL_PRIMARY_HOST:-mongodb}
MONGODB_INITIAL_PRIMARY_PORT_NUMBER: ${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}
MONGODB_ADVERTISED_HOSTNAME: ${MONGODB_ADVERTISED_HOSTNAME:-mongodb}
MONGODB_ENABLE_JOURNAL: ${MONGODB_ENABLE_JOURNAL:-true}
ALLOW_EMPTY_PASSWORD: ${ALLOW_EMPTY_PASSWORD:-yes}
output of docker compose config:
services:
mongodb:
environment:
ALLOW_EMPTY_PASSWORD: "yes"
MONGODB_ADVERTISED_HOSTNAME: mongodb
MONGODB_ENABLE_JOURNAL: "true"
MONGODB_INITIAL_PRIMARY_HOST: mongodb
MONGODB_INITIAL_PRIMARY_PORT_NUMBER: "27017"
MONGODB_PORT_NUMBER: "27017"
MONGODB_REPLICA_SET_MODE: primary
MONGODB_REPLICA_SET_NAME: rs0
image: docker.io/bitnami/mongodb:4.4
networks:
default: null
restart: on-failure
volumes:
- type: volume
source: mongodb_data
target: /bitnami/mongodb
volume: {}
rocketchat:
depends_on:
mongodb:
condition: service_started
environment:
DEPLOY_METHOD: docker
MONGO_OPLOG_URL: mongodb://$${MONGODB_ADVERTISED_HOSTNAME:-mongodb:27017/local?replicaSet=rs0}
MONGO_URL: mongodb://$${MONGODB_ADVERTISED_HOSTNAME:-mongodb:27017/rocketchat?replicaSet=rs0}
PORT: "3000"
ROOT_URL: http://localhost:$${HOST_PORT:-3000}
expose:
- "3000"
image: registry.rocket.chat/rocketchat/rocket.chat:5.0.6
labels:
traefik.enable: "true"
traefik.http.routers.rocketchat.entrypoints: https
traefik.http.routers.rocketchat.tls: "true"
traefik.http.routers.rocketchat.tls.certresolver: le
networks:
default: null
ports:
- mode: ingress
host_ip: 0.0.0.0
target: 3000
published: 3000
protocol: tcp
restart: on-failure
networks:
default:
name: documents_default
volumes:
mongodb_data:
name: documents_mongodb_data
driver: local
EDIT: This is the config output after running without an .env
file. Using the .env file results in a different error than the one in this issue.
Still an issue !
TypeError [ERR_INVALID_URL] [ERR_INVALID_URL]: Invalid URL: mongodb://${MONGODB_ADVERTISED_HOSTNAME:-mongodb:27017
at new NodeError (internal/errors.js:322:7)
at onParseError (internal/url.js:270:9)
at new URL (internal/url.js:346:5)
at new HostAddress (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/utils.js:1023:36)
at fromString (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/utils.js:1073:16)
at Array.map (<anonymous>)
at parseOptions (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/connection_string.js:220:45)
at new MongoClient (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/mongo_client.js:62:63)
at new MongoConnection (packages/mongo/mongo_driver.js:184:3)
at new MongoInternals.RemoteCollectionDriver (packages/mongo/remote_collection_driver.js:4:16)
at Object.<anonymous> (packages/mongo/remote_collection_driver.js:37:10)
at Object.defaultRemoteCollectionDriver (packages/underscore.js:784:19)
at new Collection (packages/mongo/collection.js:106:40)
at new AccountsCommon (packages/accounts-base/accounts_common.js:41:18)
at new AccountsServer (packages/accounts-base/accounts_server.js:29:5)
at packages/accounts-base/server_main.js:7:12 {
input: 'mongodb://${MONGODB_ADVERTISED_HOSTNAME:-mongodb:27017',
code: 'ERR_INVALID_URL'
}
Even after upgrading to docker compose v2
Noticed the difference in variable expansion between those lines
MONGO_URL: "${MONGO_URL:-\
mongodb://...
https://github.com/RocketChat/Docker.Official.Image/blob/master/compose.yml#L15
MONGO_OPLOG_URL: "${MONGO_OPLOG_URL:\
-mongodb://...
https://github.com/RocketChat/Docker.Official.Image/blob/master/compose.yml#L18
I tried with inline values (without \
) -> same issue 🔴
MONGO_URL: "${MONGO_URL:-mongodb://${MONGODB_ADVERTISED_HOSTNAME:-mongodb}:${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}/${MONGODB_DATABASE:-rocketchat}?replicaSet=${MONGODB_REPLICA_SET_NAME:-rs0}}"
MONGO_OPLOG_URL: "${MONGO_OPLOG_URL:-mongodb://${MONGODB_ADVERTISED_HOSTNAME:-mongodb}:${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}/local?replicaSet=${MONGODB_REPLICA_SET_NAME:-rs0}}"
And finally I kinda hard-coded the values too 🤷 ✅
MONGO_URL: ${MONGO_URL:-mongodb://mongodb:27017/rocketchat?replicaSet=rs0}
MONGO_OPLOG_URL: ${MONGO_URL:-mongodb://mongodb:27017/local?replicaSet=rs0}
There's clearly an issue related to variable expansion, in that compose.yml
file or in Docker's code
To replicate follow: https://docs.rocket.chat/quick-start/deploying-rocket.chat/rapid-deployment-methods/docker-and-docker-compose