Just for some background, I am setting up mediawiki on a raspberry pi3 for a personal learning project.
I have followed the guide from https://peppe8o.com/personal-mediawiki-with-raspberry-pi-and-docker/ and have been able to follow all but the very last step of running 'docker-compose up -d' and get the error below (I have also pasted the contents of my docker-compose.yml)
I would greatly appreciate if anyone could spot the issue here as I have tried a number of things
(removing and adding spaces in lines 6 & 17 etc....)
pi#raspberrypi:~/mediawiki $ docker-compose up -d
ERROR: yaml.parser.ParserError: while parsing a block mapping
in "./docker-compose.yml", line 6, column 3
expected <block end>, but found '-'
in "./docker-compose.yml", line 17, column 3
Contents of docker-compose.yml:
# My MediaWiki
# from peppe8o.com
version: '3'
services:
mediawiki:
image: mediawiki
restart: unless-stopped
ports:
- 8080:80
links:
- database
volumes:
- mediawiki-www:/var/www/html
#After initial setup, download LocalSettings.php to the same directory as
#this yaml and uncomment the following line and use compose to restart
#the mediawiki service
- ./LocalSettings.php:/var/www/html/LocalSettings.php
database:
build: .
restart: unless-stopped
volumes:
- mediawiki-db:/var/lib/mysql
volumes:
mediawiki-www:
mediawiki-db:
Kind regards
Layerz
Related
I'm trying to specify a container should not use cache when docker builds the container. Support for the --no-cache command-line argument was added in docker-compose 2.4.0. This works fine for me, no trouble at all.
It is also listed in the official compose file build reference, see types.go line 313 and compose-spec.json, line 98.
However, when I try to add any variation of no_cache: true under my compose.yaml build: stanza, I get the following error:
ERROR: The Compose file '/opt/docker-compose.yaml' is invalid because: services.pleroma.build contains unsupported option: 'no_cache'
Am I using incorrect syntax here, or is this simply not possible to currently do in the compose file itself? Below is the entire config for the image I want to build.
pleroma:
image: pleroma
hostname: pleroma
container_name: pleroma
networks:
dockerapps:
ipv4_address: 172.18.0.77
healthcheck:
test:
[
"CMD-SHELL",
"wget -q --spider --proxy=off localhost:4000 || exit 1",
]
restart: unless-stopped
build:
context: /opt/pleroma/.
dockerfile: /opt/pleroma/Dockerfile
no_cache: true
# Feel free to remove or override this section
# See 'Build-time variables' in README.md
args:
- "UID=1000"
- "GID=1000"
- "PLEROMA_VER=develop"
volumes:
- ./uploads:/var/lib/pleroma/uploads
- ./static:/var/lib/pleroma/static
- ./config.exs:/etc/pleroma/config.exs:ro
- ./config-override.exs:/var/lib/pleroma/config.exs:ro
env_file:
- /opt/pleroma/.docker.env
depends_on:
- pleroma_db
I'm new to Docker and I'm following a tutorial that was made for Linux (I'm using Windows). I am trying to change a ./script.sh command with one that uses a PowerShell script. &script.ps1 does not work. Here is the code:
version: "3.8"
services:
frontend:
depends_on:
- backend
build: ./frontend
ports:
- 3000:3000
backend:
depends_on:
- db
build: ./backend
ports:
- 3001:3001
environment:
DB_URL: mongodb://db/vidly
volumes:
- ./backend:/app
command: &script.ps1 # instead of ./script.sh
db:
image: mongo:4.0-xenial
ports:
- 27017:27017
volumes:
- vidly:/data/db
volumes:
vidly:
the error I receive is
in ".\docker-compose.yml", line 22, column 14
expected alphabetic or numeric character, but found '"' in ".\docker-compose.yml", line 22, column 15
in ".\docker-compose.yml", line 22, column 14 expected alphabetic or numeric character, but found '"' in ".\docker-compose.yml", line 22, column 15
Every docker-compose.yaml first need to be a valid yaml file, you could use docker-compose config to verify it. Here, what you need to is wrap &script.ps1 with double quotation mark to make it be valid yaml:
command: "&script.ps1"
Here is my docker-compose yaml file.
version: '2.1'
services:
myservice:
environment:
- MYENVVAR={"1": "Hello"}
This gives me the following parsing error when I run docker-compose
ERROR: yaml.parser.ParserError: while parsing a block mapping
in "./my_docker_compose_.yml", line 6, column 9
expected <block end>, but found '}'
in "./my_docker_compose_.yml", line 6, column 111
How can I escape my JSON object properly so it gets sent into the container as the value of environment variable MYENVVAR?
You should define this variable as:
'FOOBAR={"foo": "bar"}'
In short:
version: '3.3'
services:
nginx:
ports:
- '80:80'
volumes:
- '/var/run/docker.sock:/tmp/docker.sock:ro'
restart: always
logging:
options:
max-size: 1g
environment:
- 'FOOBAR={"foo": "bar"}'
- a=test
image: nginx
The similar question was raised on docker bug tracking system:
https://github.com/docker/compose/issues/3878
You can validate or experiment with docker-compose settings online
by visiting a web page:
https://composerize.com/
Why this is not working on docker compose version 3?
nginx:
image: nginx
container_name: nginx
environment:
VIRTUAL_HOST: >
proj1.local,proj2.local,
proj3.local,proj4.local,proj5.local
I've a lot of virtual hosts and I need to go multilne but I receive:
ERROR: yaml.scanner.ScannerError: while scanning a simple key
in "./docker-compose.yml", line 31, column 7
could not find expected ':'
in "./docker-compose.yml", line 32, column 7
What am I doing wrong?
Tools such as Yamllint are your friend when seeing those types of errors. That said, it sometimes doesn't give you a meaningful error when failing validation.
What you have in the example is an indentation problem. You should be using:
nginx:
image: nginx
container_name: nginx
environment:
VIRTUAL_HOST: >
proj1.local,proj2.local,
proj3.local,proj4.local,proj5.local
Which will translate into:
nginx:
container_name: nginx
environment:
VIRTUAL_HOST: "proj1.local,proj2.local, proj3.local,proj4.local,proj5.local"
image: nginx
I have a local docker image which has name img_test. My docker-compose.yml file is:
version: '2'
services:
img_test:
image: img_test:latest
ports:
- "8080:80"
mysql:
image: mysql:latest
ports:
- "3636:3036"
nvidia/cuda:
image: nvidia/cuda:latest
runtime: nvidia
command: nvidia-smi
networks:
appnet:
external: true
I also have Dockerfile . When I run the command docker-compose up It throws this error.
ERROR: The Compose file './docker-compose.yml' is invalid because:
Invalid service name 'img_test' - only [a-zA-Z0-9\._\-] characters are allowed
I gave another names such as img/test, imgtest but they did not work.
I also tried build the Dockerfile in docker-compose.yml file by this command.
version: '2'
services:
app:
build: .
It gives same error for app.
What is the solution? I am new on Docker. I tested my image and it is working correctly. I dont want to push my image to Dockerhub. Is there another way to solve this problem?
It's a relatively old version of docker-compose. They had this bug in the past. Try upgrading.
https://github.com/docker/compose/issues/4754