I would like to map an external usb drive in my docker-compose.yml I used the following:
volumes:
external: true
#- bitcoin-data:/data original line commented out to attempt next line
- bitcoin-data:/run/media/directory name/external drive name/docker-base
However when running docker-compose up I receive the following:
ERROR: yaml.parser.ParserError: while parsing a block mapping
in "./docker-compose.yml", line 5, column 5
expected <block end>, but found '<scalar>'
in "./docker-compose.yml", line 16, column 8
Line 5 refers to the image and Line 16 refers to the external drive I am
attempting to save data destination.
You cannot add a list in a yaml file just after a variable, that's why you have this error. If you want to add the external parameter, you will have to put the volumes's path into you container section, and the external setting into the volumes section, like:
services:
yourcontainer:
[...]
volumes:
- bitcoin-data:/run/media/directory name/external drive name/docker-base
volumes:
bitcoin-data:
external: true
Related
It seems when my docker compose yml is run via "az containerapp compose create", environment variables are not picked up. Is there a way I can set an env variable so the command picks it up?
I'm seeing this error:
ERROR: The following field(s) are either invalid or missing. Invalid value: "${DOCKER_REGISTRY-}/sample-blazorapp": could not parse reference: ${DOCKER_REGISTRY-}/sample-blazorapp: template.containers.blazorapp.image.
I have set the variable with: export DOCKER_REGISTRY="myregistry"
And when I echo $DOCKER_REGISTRY, the value is returned. So in the bash session it is set (I tried powershell first, I thought that was the issue because $(envvar-) is bash syntax, however the error is the same.)
This is what I have in my compose file (alignment is correct in the file):
blazorapp:
container_name: "blazorapp"
image: ${DOCKER_REGISTRY-}sample-blazorapp
build:
context: .
dockerfile: BlazorApp/BlazorApp/Dockerfile
depends_on:
- redis
ports:
- "55000:443"
If I explicitly set the image name, i.e. not use an env var, then it works. i.e. this change to the image line works:
image: myregistry/sample-blazorapp
I also tried adding the forward slash, this makes no difference (as expected, it works fine without the slash when running docker compose up).
I can set it explicitly but that would be annoying. I feel like I'm missing something. Any help or guidance is greatly appreciated :)
If the image is defined like this into you docker compose file:
image: ${DOCKER_REGISTRY-}sample-blazorapp
then you must export using a slash at the end of the value:
export DOCKER_REGISTRY="myregistry/"
I discovered the issue, I was missing a colon.
Does not work (produces the error described in the question):
image: ${DOCKER_REGISTRY-}sample-blazorapp
Also does not work:
image: ${DOCKER_REGISTRY-mydefault}sample-blazorapp
Add the magic : in and it works:
image: ${DOCKER_REGISTRY:-}sample-blazorapp
Also works:
image: ${DOCKER_REGISTRY:-mydefault}sample-blazorapp
I'm trying to setup selenoid and I'm having trouble with dockercomposer, it throws exception as below:
yaml.parser.ParserError: while parsing a flow mapping in "./docker-compose.yml", line 1, column 1 expected ',' or '}', but got '{' in "./docker-compose.yml", line 2, column 1
when I try to run docker command "$ sudo docker-compose up -d"
I'm in the terminal with same folder where docker-compose.yml present and content is as below,
version: '3'
services:
selenoid:
network_mode: bridge
image: aerokube/selenoid
volumes:
- "/docker:/etc/selenoid"
- "/var/run/docker.sock:/var/run/docker.sock"
- "/docker/video:/opt/selenoid/video"
environment:
- OVERRIDE_VIDEO_OUTPUT_DIR=/opt/selenium/video
- TZ=Europe/Amsterdam
command: ["-conf", "/etc/selenoid/browsers.json", "-video-output-dir", "/opt/selenoid/video"]
ports:
- "4444:4444"
I've also tried many online yml parsers and there is nothing wrong with yml file. Any help would be much appreciated.
Thanks
Sorry being late to answer my own post, there was nothing wrong with YML file, I should have created/edited it using programming editors such as IntelliJ, but I was editing and saving it using EditText. All worked fine after editing them and saving using IntelliJ in mac.
I am building my first docker-compost.yml file, but can not seem to get the errors to clear when I run docker-compose config. I keep getting the following:
ERROR: yaml.parser.ParserError: while parsing a block mapping in "./docker-compose.yml", line 1, column 1 expected <block end>, but found '<block mapping start>' in "./docker-compose.yml", line 2, column 5
Below is the configuration of the .yml file. I am sure it is something really simple, but I have never done anything like this before. O if it means anything I am using Notepad++ to edit.
version: '3'
services:
googlehomekodi:
image: omertu/googlehomekodi
ports:
- "8099:8099"
environment:
- KODI_PROTOCOL=http
- KODI_IP=192.168.1.212
- KODI_PORT=8080
- KODI_USER=kodi
- KODI_PASSWORD=kodi
- AUTH_TOKEN=stuff
restart: always
ok this is driving me nuts already. What I just want to do is launch php:5.6-apache image and mount my ./web to /var/www/html by having the following docker-compose.yml file:
version: '2'
services:
apache:
image: php:5.6-apache
volumes:
- ./web:/var/www/html
ports:
- 8081:80
Launching it with docker-compose up.
For some unknown reason this results in empty /var/www/html folder, although it should contain what I have in ./web.
Or I am doing it wrong?
Well, it turned out that for some reason windows firewall prevented folder sharing. It seems that it was because DockerNat network was listed among Public networks, so I had to run the following commands in elevated power shell:
$Profile = Get-NetConnectionProfile -InterfaceAlias "vEthernet (DockerNAT)"
$Profile.NetworkCategory = "Private"
Set-NetConnectionProfile -InputObject $Profile
Then I was able to enable drive sharing in docker settings and then mounted folders became filled with files.
[UPDATE 2018-05-03] There's a good gist that will put dockerNat network to private when you restart docker. All you have to do is modify MobyLinux.ps1 file located at C:\Program Files\Docker\Docker\resources by adding include at 86, function at 182-186 and modifying lines try/catch statement at 399-409 to include Set-Switch-Private function calls.
Example:
my-server:
image: my-server:latest
ports:
- 1234:1234
proxy:
image: lb:latest
environment:
- BACKEND=${VAR}??? # must be resolve as 'my-server'
The server name can be changed to any name, but the proxy has a entry-point script where the variable will be substituted in the BACKEND to config.
You can use a .env file to define your variable. This file will be placed in the same directory as your docker-compose.yml file.
When you run docker-compose, it will read this value and use it. Using your example, your .env file would look something like this:
VAR=my-server
and, the line:
- BACKEND=${VAR}??? # must be resolve as 'my-server'
would become just:
- BACKEND=${VAR}
or
BACKEND: ${VAR}