10

I'm working with a poor internet connection and trying to pull and run a image.

I wanted to download one layer at a time and per documentation tried adding a flat --max-concurrent-downloads like so:

docker run --rm -p 8787:8787 -e PASSWORD=blah --max-concurrent-downloads=1 rocker/verse

But this gives an error:

unknown flag: --max-concurrent-downloads See 'docker run --help'.

I tried typing docker run --help and interestingly did not see the option --max-concurrent-downloads.

I'm using Docker Toolbox since I'm on a old Mac.

Over here under l there's an option for --max-concurrent-downloads however this doesn't appear on my terminal when typing docker run --help

enter image description here

How can I change the default of downloading 3 layers at a time to just one?

Doug Fir
  • 19,971
  • 47
  • 169
  • 299
  • Possible duplicate of [How to pull layers one by one in Docker?](https://stackoverflow.com/questions/41303784/how-to-pull-layers-one-by-one-in-docker) – tgogos May 17 '19 at 10:20
  • I took a look at the post that you linked to. The accepted solution comments say to edit a file in /etc/docker/ however /etc/docker does not exist in my file structure. The answer further down suggests ```sudo service docker stop``` however this gives me "dockerd: command not found" – Doug Fir May 17 '19 at 10:26

2 Answers2

17

From the official documentation: (https://docs.docker.com/engine/reference/commandline/pull/#concurrent-downloads)

You can pass --max-concurrent-downloads during a pull operation.

You can set --max-concurrent-downloads with the dockerd command.

If you're using the docker Desktop GUI for Mac or Windows:

You can edit the .json file directly in docker engine settings:

Docker engine configs

Orangutech
  • 769
  • 1
  • 10
  • 17
AndreDurao
  • 5,600
  • 7
  • 41
  • 61
7

This setting needs to be passed to dockerd when starting the daemon, not to the docker client CLI. The dockerd process is running inside of a VM with docker-machine (and other docker desktop environments).

With docker-machine that is used in toolbox, you typically pass the engine flags on the docker-machine create command line, e.g.

docker-machine create --engine-opt max-concurrent-downloads=1

Once you have a created machine, you can follow the steps from these answers to modify the config of an already running machine, mainly:

  1. SSH into your local docker VM.
    note: if 'default' is not the name of your docker machine then substitute 'default' with your docker machine name $ docker-machine ssh default

  2. Open Docker profile $ sudo vi /var/lib/boot2docker/profile

Then in that profile, you would add your --engine-opt max-concurrent-downloads=1.


Newer versions of docker desktop (along with any Linux install) make this much easier with a configuration menu daemon -> advanced where you can specify your daemon.json entries like:

{
  "max-concurrent-downloads": 1
}
BMitch
  • 231,797
  • 42
  • 475
  • 450
  • ***NOT WORKING***, I set max-concurrent-downloads from the settings for docker engine but after restart and pull the image still getting multiple downloads. – Nasser Ali Karimi Sep 27 '22 at 09:10