I'm trying to run mockoon docker cli using docker compose for my mock api and i have the json exported to my directory,
version: "3"
services:
mockoon:
image: mockoon/cli:latest
command: mockoon-cli start
networks:
demo:
ports:
- "8001:8001"
volumes:
- type: bind
source: ./mock.json
target: /www
networks:
demo:
when i run docker-compose up the container comes up for few seconds and shuts down with the following log
› Error: Missing required flag:
› -d, --data DATA Path(s) or URL(s) to your Mockoon data file(s)
› See more help with --help
Any additional settings that i should make or i have missed something in my config.
I have checked the official documentation, you need to specify the --data directory inside the docker-compose command line.
So the compose file would like like this:
version: "3"
services:
mockoon:
image: mockoon/cli:latest
command: mockoon-cli start --data <directory> # this is where the change takes place
networks:
demo:
ports:
- "8001:8001"
volumes:
- type: bind
source: ./mock.json
target: /www
networks:
demo:
mockoon cli
The "data" after the --data flag is the alias to the file name, not the folder name. Hence, it should be:
version: "3"
services:
chicargo-mockoon-mock:
platform: linux/amd64
image: mockoon/cli:latest
ports:
- "8001:8001"
volumes:
- type: bind
source: ./your-file-name.json
target: /data
command: mockoon-cli start --data data
Related
Blessings,
I've got a docker-compose.yml and I am trying to push it to Azure container registry but it skips the upload.
# docker-compose.yml
version: '3'
services:
proxy:
image: nginx:1.17.3
ports:
- 80:80
- 443:443
volumes:
# Mount the nginx folder with the configuration
- ./nginx:/etc/nginx:ro
# Mount the letsencrypt certificates
- /etc/letsencrypt:/etc/letsencrypt:ro
fdp:
image: fairdata/fairdatapoint:1.15
volumes:
- ./application.yml:/fdp/application.yml:ro
fdp-client:
image: fairdata/fairdatapoint-client:1.15
environment:
- FDP_HOST=fdp
mongo:
image: mongo:4.0.12
ports:
- "127.0.0.1:27017:27017"
volumes:
- ./mongo/data:/data/db
blazegraph:
image: metaphacts/blazegraph-basic:2.2.0-20160908.003514-6
volumes:
- ./blazegraph:/blazegraph-data
I know the above has to be edited according to this documentation
But I couldn't quite understand how the changes should be applied and would need some guidance.
I've tried building successfully using docker-compose up --build -d then docker-compose push returns the the following
[+] Running 5/0
- blazegraph Skipped 0.0s
- proxy Skipped 0.0s
- fdp Skipped 0.0s
- fdp-client Skipped 0.0s
- mongo Skipped
I've had to add a dockerfile and change the following inside my docker-compose
app:
build: .
image: foo.azurecr.io/foo
container_name: foo
Prefix should be used when trying to push to ACR.
Dockerfile was just a simple python application installing dependencies, It is required to push so It was kept basic.
I prepared docker-compose.yml for the docker registry and now I want to define some UI microservice for it.
I am using docker-compose version 3 but the instruction is written for version 1 or 2.
I should add to registry microservice some HTTP HEADERS:
Access-Control-Allow-Origin: ['http://localhost:8080']
Access-Control-Allow-Credentials: [true]
Access-Control-Allow-Headers: ['Authorization', 'Accept']
Access-Control-Allow-Methods: ['HEAD', 'GET', 'OPTIONS']
My docker-compose.yml:
version: "3.5"
networks:
docker-registry-ui-net:
services:
registry:
restart: always
image: registry:2
ports:
- 5000:5000
environment:
REGISTRY_HTTP_TLS_CERTIFICATE: /certs/domain.crt
REGISTRY_HTTP_TLS_KEY: /certs/domain.key
REGISTRY_AUTH: htpasswd
REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm
volumes:
- ./data:/var/lib/registry
- ./certs:/certs
- ./auth:/auth
networks:
- docker-registry-ui-net
ui:
image: joxit/docker-registry-ui:latest
ports:
- 8080:80
environment:
REGISTRY_TITLE: 'My Private Docker Registry'
REGISTRY_URL: http://localhost:5000
depends_on:
- registry
networks:
- docker-registry-ui-net
How can I do it using docker-compose file in version 3?
A bit late reply, but maybe someone find it useful
You can override registry config by mounting volume file like in this examle https://github.com/Joxit/docker-registry-ui/tree/main/examples/proxy-headers
mount this file:
- ./registry-config/credentials.yml:/etc/docker/registry/config.yml
Currently I have setup my service like the following.
version: '3'
services:
gateway:
container_name: gateway
image: node:lts-alpine
working_dir: /
volumes:
- ./package.json:/package.json
- ./tsconfig.json:/tsconfig.json
- ./services/gateway:/services/gateway
- ./packages:/packages
- ./node_modules:/node_modules
env_file: .env
command: yarn run ts-node-dev services/gateway --colors
ports:
- 3000:3000
So I have specified one env_file. But now I want to pass multiple .env files.
Unfortunately, the following is not possible:
env_files:
- .env.secrets
- .env.development
Is there any way to pass multiple .env files to one service in docker-compsoe?
You can specify multiple env files on the env_file option (without s).
For instance:
version: '3'
services:
hello:
image: alpine
entrypoint: ["sh"]
command: ["-c", "env"]
env_file:
- a.env
- b.env
Note that, complementary to #conradkleineespel's answer, if an environment variable is defined in multiple .env files listed under env_file, the value found in the last environment file in the list overwrites all prior (tested in a docker-compose file with version: '3.7'.
I am trying to learn how to utilize docker-compose and was following instructions until I received an error. Here's my docker-compose file.
version: '3.7'
services:
web:
build: ./app
command: python /usr/src/app/manage.py runserver 0.0.0.0:8000
volumes:
- ./app/:/usr/src/app/
ports:
- 8000:8000
environment:
- SECRET_KEY=my_secret_key
- SQL_ENGINE=django.db.backends.postgresql
- SQL_DATABASE=postgres
- SQL_USER=postgres
- SQL_PASSWORD=postgres
- SQL_HOST=db
- SQL_PORT=5432
depends_on:
- db
db:
images: postgres:10.7-alpine
volumes:
- postgres_data:/var/lib/postgresql/data/
volumes:
postgres_data:
When I go back and enter "docker-compose up -d --build", I would get an error saying
ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for services.db: 'images'
I think I have the indentation correct and 'images' look okay to me.
My docker-compose version is 1.23.2 and trying to run this on Mac.
Any ideas? thanks in advance.
It should be image not images.
I am using docker-compose file generated by docker-app
docker-app render | docker-compose -f - up
The docker app file looks like this and it works as expected. But I am not able to use volumes.
I use -v parameter while using docker run command like this...
-v /my/custom3399:/etc/mysql/conf.d
-v /storage/mysql/datadir3399:/var/lib/mysql
How do I declare volumes in compose file?
# vi hello.dockerapp
# This section contains your application metadata.
# Version of the application
version: 0.1.0
# Name of the application
name: hello
# A short description of the application
description:
# Namespace to use when pushing to a registry. This is typically your Hub username.
#namespace: myHubUsername
# List of application maitainers with name and email for each
maintainers:
- name: root
email:
# Specify false here if your application doesn't support Swarm or Kubernetes
targets:
swarm: false
kubernetes: false
--
# This section contains the Compose file that describes your application services.
version: "3.5"
services:
mysql:
image: ${mysql.image.version}
environment:
MYSQL_ROOT_PASSWORD: india${mysql.port}
ports:
- "${mysql.port}:3306"
--
# This section contains the default values for your application settings.
mysql.image.version: shantanuo/mysql:5.7
mysql.port: 3391
update:
The script mentioned above works well. But once I add volumes, I get an error:
version: "3.5"
services:
mysql:
image: ${mysql.image.version}
environment:
MYSQL_ROOT_PASSWORD: india${mysql.port}
ports:
- "${mysql.port}:3306"
volumes:
- type: volume
source: mysql_data
target: /var/lib/mysql
volumes:
mysql_data:
external: true
And the error is:
docker-app render | docker-compose -f - up
Recreating e5c833e2187d_hashi_mysql_1 ... error
ERROR: for e5c833e2187d_hashi_mysql_1 Cannot create container for service mysql: Duplicate mount point: /var/lib/mysql
ERROR: for mysql Cannot create container for service mysql: Duplicate mount point: /var/lib/mysql
ERROR: Encountered errors while bringing up the project.
As mentioned in the comment, the rendered output is as follows:
# /usr/local/bin/docker-app render
version: "3.5"
services:
mysql:
environment:
MYSQL_ROOT_PASSWORD: india3391
image: shantanuo/mysql:5.7
ports:
- mode: ingress
target: 3306
published: 3391
protocol: tcp
volumes:
- type: volume
source: mysql_data
target: /var/lib/mysql
volumes:
mysql_data:
name: mysql_data
external: true
This issue was resolved once I changed the directory name.
# cd ..
# mv hashi/ hashi123/
# cd hashi123
Not sure how this worked. But since I am able to start the server stack, I am posting it as answer.