Docker hello-world does not work - docker

Operating System: Mac OS X
I installed boot2docker and started it, some errors are shown:
wangyaos-MBP-2:~ wangyao$ boot2docker start
Waiting for VM and Docker daemon to start...
..........................o
Started.
Writing /Users/wangyao/.boot2docker/certs/boot2docker-vm/ca.pem
Writing /Users/wangyao/.boot2docker/certs/boot2docker-vm/cert.pem
Writing /Users/wangyao/.boot2docker/certs/boot2docker-vm/key.pem
To connect the Docker client to the Docker daemon, please set:
export DOCKER_TLS_VERIFY=1
export DOCKER_HOST=tcp://192.168.59.103:2376
export DOCKER_CERT_PATH=/Users/wangyao/.boot2docker/certs/boot2docker-vm
wangyaos-MBP-2:~ wangyao$ boot2docker shellinit
Writing /Users/wangyao/.boot2docker/certs/boot2docker-vm/ca.pem
Writing /Users/wangyao/.boot2docker/certs/boot2docker-vm/cert.pem
Writing /Users/wangyao/.boot2docker/certs/boot2docker-vm/key.pem
export DOCKER_HOST=tcp://192.168.59.103:2376
export DOCKER_CERT_PATH=/Users/wangyao/.boot2docker/certs/boot2docker-vm
export DOCKER_TLS_VERIFY=1
wangyaos-MBP-2:~ wangyao$ docker run hello-world
Post http:///var/run/docker.sock/v1.19/containers/create: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?
What do I need to do to make $ docker run hello-world work?

Instead of running boot2docker shellinit, you need to do the following in your current shell:
eval "$(boot2docker shellinit)"
The boot2docker shellinit command prints the required export statements to standard out. These statements set the required environment variables for connecting to the boot2docker virtual machine.
By wrapping the output of boot2docker shellinit with eval $(), the variables will be exported in the current shell instead of just printed. This should allow you to connect to the boot2docker vm, which is required for running the example.

Related

dockerd --max-concurrent-downloads 1 command not found [duplicate]

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
How can I change the default of downloading 3 layers at a time to just one?
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:
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:
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
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
}

Issue with setting up docker on WSL in Windows 10 Home

I am trying to setup docker through WSL(ubuntu) on Windows 10 Home but ran into an issue when trying to use the docker-compose up command:
$ docker-compose up
ERROR: Couldn't connect to Docker daemon at http://localhost:2375 - is it running?
I have the following configuration in my ~/.bashrc file
#Insert new Path for Docker and Alias
PATH="$HOME/bin:$HOME/.local/bin:$PATH"
PATH="$PATH:/mnt/c/Program Files/Docker Toolbox"
alias docker=docker.exe
alias docker-machine=docker-machine.exe
// Other code
export DOCKER_HOST='tcp://localhost:2375'
docker-machine seems to be running fine as the docker ps command shows a list of containers.
From my research, if I were to use Docker for Windows (which does not run on Windows Home) ; I need to turn on the “Expose daemon on tcp://localhost:2375 without TLS” option in the settings. Since I am using “Docker Toolbox + VirtualBox”, I would like to ask what would be the equivalent?
Please let me know if you require further information.
This is a bit tricky because yo need to use two terminals : one in Windows and one in WSL.
What worked for me : I installed docker-machine and virtualbox on Windows. Then I created a virtual machine named default on virtualbox. Then on Windows, with the terminal Git bash for windows, I ran the following commands :
docker-machine start default : it starts the virtual machine. Alternatively, you can start it directly on virtualbox
docker-machine env default: it shows the commands needed to start the linux shell.
Output looks like this
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.101:2376"
export DOCKER_CERT_PATH="C:\Users\<yourusername>\.docker\machine\machines\default"
export DOCKER_MACHINE_NAME="default"
export COMPOSE_CONVERT_WINDOWS_PATHS="true"
# Run this command to configure your shell:
# eval $("C:\ProgramData\chocolatey\lib\docker-machine\bin\docker-machine.exe" env default)
Then you switch to WSL. You can access the terminal by typing ubuntu in the research bar
In /.bashrc, you paste the output (replace with your own output)
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.101:2376"
export DOCKER_CERT_PATH="/mnt/c/Users/<yourusername>/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
export COMPOSE_CONVERT_WINDOWS_PATHS="true"
Note that I changed the DOCKER_CERT_PATH so that it works on a linux environment
Finally, in WSL, run source /.bashrc
You can then test your install by running docker run hello-world
Remember to keep your virtual machine running.
The following two articles really helped me with the install:
https://www.sitepoint.com/docker-windows-10-home/
https://www.paraesthesia.com/archive/2018/09/20/docker-on-wsl-with-virtualbox-and-docker-machine/

Cannot run docker 'hello world' example

I just installed docker on a Mac (docker toolbox from here; at least I hope to have it installed correctly), but when following the tutorial and type the following command
docker run hello-world
I get the following error:
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
Did I do something wrong? Do I miss some installation steps? Do I miss something that is 'obvious' to the experts, but not to docker beginners like me?
I don't see anything in the instructions that says anything about a 'docker daemon'...
On the shell it says:
docker is configured to use the default machine with IP aa.bb.cc.d
The version command seems to work:
Docker version 17.07.0-ce, build 8784753
Update:
I tried to start the daemon by using the command
sudo dockerd
but all I got was
sudo: dockerd: command not found
Correction: The command works, but only in the sell that opened magically during the installation. The command does not work in any other shell. But when I have to close the shell/restart the computer - what to do then? How to 'start docker???
Maybe there is a tutorial that is complete and working and explains why I need a docker-deacon, how to start it, how to start a docker image or whatever, including the complete terminology for beginners?
Docker Toolbox runs a virtual linux machine on which the docker-daemon runs. To control the virtual machine, you use the docker-machine command. For example docker-machine start to start the machine after you reboot your computer, or docker-machine stop to shut it down.
There is also the docker-machine env command which will set the environment variables needed for docker to work. Check the bottom line of it's output, it shows you how to run the command correctly to set the environment variables. Should be exec $(docker-machine env) on Mac if I'm correct. You need to set the environment variables in each shell in which you want to use docker commands.
Docker for mac starts a linux virtual machine in the background which contains the actual docker stuff. When you start a normal terminal, the terminal is not connected to the vm to execute the docker commands.
The docker quick start terminal is the one that you need to use. This terminal will execute the commands on the VM that is running in the background.
With docker toolbox, if you don't launch your terminal from the docker menu, you'll need to configure your environment separately:
eval "$(docker-machine env default)"

Docker commands fail in Cygwin -- Docker service is up

I'm trying to login to my AWS account with a docker loginstring from aws ecr get-login --region eu-west-1 -- however, when I do, I get this:
Warning: failed to get default registry endpoint from daemon (error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.26/info: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.). Using system default: https://index.docker.io/v1/
error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.26/auth: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running
The peculiar thing is this was just working last week. I'm using Cygwin on Windows 10. I've verified that Docker is running in services.msc -- I'm not entirely sure what to check now.
If you want to run docker commands in cygwin on Windows 10, then call the following command from cygwin:
docker-machine env --shell=bash
It will show the environment variables needed by docker:
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.xx.xx:2376"
export DOCKER_CERT_PATH="C:\Users\...\machines\default"
export DOCKER_MACHINE_NAME="default"
export COMPOSE_CONVERT_WINDOWS_PATHS="true"
# Run this command to configure your shell:
# eval $(docker-machine env --shell=bash)
Run the following command to set the environment variables:
eval $(docker-machine env --shell=bash)
It looks like you are trying to open a pipe to the service by passing a windows pipe path to cygwin. It gets interpreted as an http path by cygwin.
This is probably happening because the docker command finds the cygwin python before it finds the windows python. There are several solutions. The simplest is to switch back to a windows context to execute the docker command. If docker is actually docker.bat then start it with cmd.exe /c docker.bat otherwise cmd.exe /c docker.exe. You may also try cmd.exe /c start /w /i docker.bat. Or some variation.
You do not want to execute any docker command directly in cygwin as it will likely not know how to translate between windows paths and the linux paths it expects.

Error in Docker: bad address to executables

I'm trying to something with Docker.
Steps I'm doing:
- Launch Docker Quickstart Terminal
- run docker run hello-world
Then I get error like:
bash: /c/Program Files/Docker Toolbox/docker: Bad address
I have to say that I was able to run hello-world image, but now I'm not. I don't know what happend.
I don't know if it matters however I had some problems at instalation step.
Since I have git installed in non standard location. However it seems git bash.exe working correctly for Docker.
My environment:
Windows 10
Git 2.5.0 (installed before Docker)
Docker Toolbox 1.9.1a
I have the same issue with bash: /c/Program Files/Docker Toolbox/docker: Bad address
I thought the problems is "bash doesn't support docker.exe".
SO I fix this problem by use powershell ,not the bash.
and if you use powershell maybe face this
An error occurred trying to connect: Get http://localhost:2375/v1.21/containers/json: dial tcp 127.0.0.1:2375: ConnectExenter code here
tcp: No connection could be made because the target machine actively refused it.
You can export variable from bash use export and import to powershell by this below
$env:DOCKER_HOST="tcp://192.168.99.100:2376"
$env:DOCKER_MACHINE_NAME="default"
$env:DOCKER_TLS_VERIFY="1"
$env:DOCKER_TOOLBOX_INSTALL_PATH="C:\\Program Files\\Docker Toolbox"
$env:DOCKER_CERT_PATH="C:\\Users\\kk580\\.docker\\machine\\machines\\default"
that's all
ps:I found this problem fixed by update git from 2.5.0 to 2.6.3.
Not entirely sure what the issue is, report it to the project on github. I find the docker mac and windows tools a bit flakey from time to time as they are still maturing. If you don't mind seeing what's underneath, you can try running docker-machine directly or set up your own host pretty quickly with Vagrant.
Docker Machine
Run a command or bash prompt to see what machines you have.
docker-machine ls
Create a machine if you don't have one listed
docker-machine create -d "virtualbox" default-docker
Then connect to the listed machine (or default-docker)
docker-machine ssh default-docker
Vagrant
If that doesn't work you can always use vagrant to manage VM's
Install VirtualBox (Which you probably have already if you installed the toolbox)
Reinstall Git, make sure you select the option for adding ALL the tools to your system PATH (for vagrant ssh)
Install Vagrant
Run a command or bash prompt
mkdir docker
cd docker
vagrant init debian/jessie64
vagrant up --provider virtualbox
Then to connect to your docker host you can run (from the same docker directory you created above)
vagrant ssh
Now your on the docker host, Install the latest docker the first time
curl https://get.docker.com/ | sudo sh
Docker
Now you have either a vagrant or docker-machine host up, you can docker away after that.
sudo docker run -ti busybox bash
You could also use PuTTY to connect to vagrant machines instead of installing git/ssh and running vagrant ssh. It provides a nicer shell experience but it requires some manual setup of the ssh connections.

Resources