18

I want to mount a directory from the host to a container using the mount flag over volume but I am getting ` This is only experienced when using mount flag and not with volume

*Command:*
    docker run -d  -it  --name devtest --mount type=bind,source="$(pwd)",target=/home/  httpd

Error unknown flag: --mount

Server Version: 1.13.1
Storage Driver: aufs
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: "deleted" 
Profile: default
Kernel Version: 4.10.0-42-generic
Operating System: Ubuntu 17.04
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.715 GiB
Name: "deleted"
ID: "deleted"
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Ndifreke
  • 732
  • 1
  • 8
  • 13

1 Answers1

23

docker run support for the --mount option was only introduced in Docker 17.06. You are using Docker 1.13.1. You have two choices:

  1. Update to Docker 17.06 or later if you can;
  2. Use the -v approach to bind mount the volume you require e.g. docker run -v $(pwd):/home
Rob Lockwood-Blake
  • 4,688
  • 24
  • 22
  • 1
    Seems like Ubuntu repo has outdated version, will try to build from source or see if I can get updated repo. Thanks – Ndifreke Jan 09 '18 at 12:43
  • 2
    For people arriving in the future, find instructions for adding the proper docker repository here: https://docs.docker.com/install/linux/docker-ce/ubuntu/ The default docker.io package on apt is out of date. – Ruvi Lecamwasam Feb 18 '18 at 23:04
  • 1
    Interesting.. the version you get from get.docker.com, which is their official, endorsed way, is still 1.13.1. This is as of today, Aug 16, 2018, running the latest version of Fedora Atomic. – Blake Aug 16 '18 at 18:32
  • 18
    You also need `DOCKER_BUILDKIT=1` – Shane Jun 05 '19 at 22:24
  • 3
    I had this error in Docker 19.03 You may need to add `# syntax = docker/dockerfile:experimental` to the first line of your Docker file. – Owen Delahoy Apr 09 '21 at 04:30