Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker run with env-file and volume mounting #11822

Closed
Jorman opened this issue May 15, 2024 · 2 comments
Closed

Docker run with env-file and volume mounting #11822

Jorman opened this issue May 15, 2024 · 2 comments

Comments

@Jorman
Copy link

Jorman commented May 15, 2024

Description

Sorry for posting here, I know this is not a compose related issue, I searched if there was a better place but couldn't find anything.
I've been trying unsuccessfully for a couple of days to get this docker run to work, I don't know if I'm wrong or it's a limitation to which nothing can be done
I cant use a docker-composeso I have to use the classicdocker run, however I cant assign the variable to the volume, for example

docker run --env-file /docker-config/compose/global.env ubuntu env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=e4ffe5fc2de1
PUID=1000
PGID=100
TZ=Europe/Rome
DOCKER_APPDATA=/docker-config/appdata
DATA=/srv/dev-disk-by-uuid-1628c4f4-134e-4af8-b1de-829c5b1ed564
SHARING=/srv/dev-disk-by-uuid-ecc70552-d999-49f3-b5e4-9a0250e1c559/Sharing
UTILITIES=/utilities
HOME=/root

Here everything is ok, the variables are read, however if I try with this

docker run --env-file /docker-config/compose/global.env -v ${SHARING}:/Sharing ubuntu env
docker: invalid spec: :/Sharing: empty section between colons.
See 'docker run --help'.

Yet in docker-compose, if you specify the variables file, you can use them to mount volumes

What am I doing wrong?

Steps To Reproduce

No response

Compose Version

docker compose version
Docker Compose version v2.27.0

Docker Environment

docker info
Client: Docker Engine - Community
 Version:    26.1.2
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.14.0
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.27.0
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 40
  Running: 23
  Paused: 0
  Stopped: 17
 Images: 41
 Server Version: 26.1.2
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 nvidia runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: e377cd56a71523140ca6ae87e30244719194a521
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.6.13+bpo-amd64
 Operating System: Debian GNU/Linux 12 (bookworm)
 OSType: linux
 Architecture: x86_64
 CPUs: 12
 Total Memory: 31.2GiB
 Name: openmediavault
 ID: e7f118aa-cb52-4f48-a3e3-99b0a2278627
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

No response

@ndeloof
Copy link
Contributor

ndeloof commented May 23, 2024

As you run docker run ... with ${..} this is your shell processing to variable interpolation. This feature is specific to docker compose and does not apply to docker CLI in general. Maybe you could use source .../global.env && docker run -v ${SHARING}:/Sharing ubuntu env

@ndeloof ndeloof closed this as completed May 23, 2024
@ndeloof
Copy link
Contributor

ndeloof commented May 23, 2024

Please report docker CLI issues on github.com/docker/cli

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants