docker installed with brew fails on /var/run/docker.sock - docker

I installed docker on my Mac, using brew:
$ brew install docker
Running docker with no arguments works fine and shows a list of commands, but running a search fails like this:
$ docker search riak
FATA[0000] Get http:///var/run/docker.sock/v1.17/images/search?term=riak: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?
docker images fails the same way. How can I get this running?
Edit:
I ran
$ brew install boot2docker
$ boot2docker init
That failed with
error in run: Failed to initialize machine "boot2docker-vm": exit status 1
Hopefully this sheds some light on the situation:
$ boot2docker -v info
Boot2Docker-cli version: v1.5.0
Git commit: ccd9032
2015/03/09 12:48:51 executing: VBoxManage showvminfo boot2docker-vm --machinereadable
{
"Name": "boot2docker-vm",
"UUID": "978c667c-9e7b-4026-823e-fa9ccde98a47",
"Iso": "",
"State": "running",
"CPUs": 1,
"Memory": 128,
"VRAM": 8,
"CfgFile": "/Users/issactrotts/VirtualBox VMs/boot2docker-vm/boot2docker-vm.vbox",
"BaseFolder": "/Users/issactrotts/VirtualBox VMs/boot2docker-vm",
"OSType": "",
"Flag": 0,
"BootOrder": null,
"DockerPort": 0,
"SSHPort": 0,
"SerialFile": ""
}
Most likely DockerPort and SSHPort should not be 0.

I'm assuming that brew installed boot2docker, as there does not appear to be any other supported, non-experimental way to run Docker on a Mac. Following the instructions from that page, you need to run boot2docker init; boot2docker start and then, in every shell session in which you want to use any Docker commands, you have to run $(boot2docker shellinit) (The $(...) is required in order to execute the output of shellinit).

Related

Docker installation issue : Failed to mount overlay: no such device storage-driver=overlay2

I am trying to install docker on Ubuntu 20.04.3 LTS. I installing from *.deb packages. While installing docker, it runs into the following error.
Failed to mount overlay: no such device storage-driver=overlay2
I created
{
"storage-driver": "overlay2"
}
as per https://docs.docker.com/storage/storagedriver/overlayfs-driver/ but that did not help either.
Edit 1:
lsmod | grep overlay returns empty.
sudo modprobe overlay' returns fatal error. In fact, there are no module files under /lib/modules/' for the 'uname -a' version of the kernel.

Docker Container nvidia/k8s-device-plugin:1.9 Keeps Reporting Error

I am trying to setup one small kubenertes cluster on my ubuntu 18.04 LTS server. Now every step is done, but checking the GPU status fails. The container keeps reporting errors:
1. Issue Description
I have done steps by Quick-Start, but when I run the test case, it reports error.
2. Steps to reproduce the issue
exec shell cmd
docker run --security-opt=no-new-privileges --cap-drop=ALL
--network=none -it -v /var/lib/kubelet/device-plugins:/var/lib/kubelet/device-plugins
nvidia/k8s-device-plugin:1.9
check the erros
2020/02/09 00:20:15 Starting to serve on
/var/lib/kubelet/device-plugins/nvidia.sock
2020/02/09 00:20:15 Could not register device plugin: rpc error: code = Unimplemented desc =
unknown service deviceplugin.Registration
2020/02/09 00:20:15 Could
not contact Kubelet, retrying. Did you enable the device plugin
feature gate?
2020/02/09 00:20:15 You can check the prerequisites at:
https://github.com/NVIDIA/k8s-device-plugin#prerequisites
2020/02/09
00:20:15 You can learn how to set the runtime at:
https://github.com/NVIDIA/k8s-device-plugin#quick-start
3. Environment Information
- outputs of nvidia-docker run --rm dlws/cuda nvidia-smi
NVIDIA-SMI 440.48.02 Driver Version: 440.48.02 CUDA Version: 10.2
outputs of nvidia-docker run --rm dlws/cuda nvidia-smi
NVIDIA-SMI 440.48.02 Driver Version: 440.48.02 CUDA Version: 10.2
contents of /etc/docker/daemon.json
contents:
{
"default-runtime": "nvidia",
"runtimes": {
"nvidia": {
"path": "nvidia-container-runtime",
"runtimeArgs": []
}
}
}
docker version: 19.03.2
kubernetes version: 1.15.2
Finally I found the answer, hope this post would be helpful for others who encounter the same issue:
For kubernetes 1.15, use k8s-device-plugin:1.11 instead. The version 1.9 is not able to communicate with kubelet.

Docker run throws error when user namespaces are used with SELinux on

I am trying to get Docker user namespaces to work with SELinux enabled on Centos 7.5. However, I get this error everytime:
docker run -itd --name temp -p 80:80 httpd
1a83588651b407e547881e15190b6d39692a7a2cf2df73dcaf4f37730ebdca65
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:301: running exec setns process for init caused \"exit status 40\"": unknown.
This does not happen if I turn of SELinux.
Here is my /etc/docker/daemon.json:
{
"userns-remap": "dockerspace",
"hosts": ["unix:///var/run/docker.sock", "tcp://0.0.0.0:2376"],
"tls": true,
"tlscacert": "/etc/pki/tls/certs/docker-ca.pem",
"tlscert": "/etc/pki/tls/certs/docker-cert.pem",
"tlskey": "/etc/pki/tls/private/docker-key.pem",
"tlsverify": true,
"selinux-enabled": true
}
uname -a output:
Linux atlantis.newtarget.net 3.10.0-862.9.1.el7.x86_64 #1 SMP Mon Jul 16 16:29:36 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
cat /proc/cmdline output:
BOOT_IMAGE=/vmlinuz-3.10.0-862.9.1.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet LANG=en_US.UTF-8 namespace.unpriv_enable=1 user_namespace.enable=1
Any help is greatly appreciated. Thanks.
You've got a bit more going on than I do when I was getting that error, but here goes!
Based on your cat /proc/cmdline output it looks like you have already done:
sudo grubby --args="namespace.unpriv_enable=1" --update-kernel=/boot/vmlinuz-$(uname -r)
You might need to restart for this to take effect (if you haven't already).
You also need to make sure the value in /proc/sys/user/max_user_namespaces is at least greater than 0:
echo 12345 > /proc/sys/user/max_user_namespaces
These settings along with configuring [/etc/subuid, /etc/subgid, /etc/docker/daemon.json] correctly it worked for me with selinux enabled. docker documentation on user namespacing, how to configure the above files (must be done manually for each on centos/rhel)

ansible_default_ipv4.address undefined in docker ubuntu

I am trying to run a simple ansible operation which should update a line in /etc/hosts:
- hosts: localhost
become: true
vars:
master_host: "ansible-master"
tasks:
- hostname: name="{{master_host}}"
- name: Add master host to /etc/hosts
lineinfile: dest=/etc/hosts line="{{ ansible_default_ipv4.address}} {{master_host}}"
regexp=".*{{master_host}}\s*$"
When I run this in virtualbox with ubuntu 16, it works fine.
When I run it in my ubuntu 16 Docker container, I get:
fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field
'args' has an invalid value, which appears to include a variable that
is undefined. The error was: 'ansible_default_ipv4' is
undefined\n\nThe error appears to have been in
'/home/user/ansible/manage-ansible-master.yml': line 11, column 5, but
may\nbe elsewhere in the file depending on the exact syntax
problem.\n\nThe offending line appears to be:\n\n - hostname:
name=\"{{master_host}}\"\n - name: Add master host to /etc/hosts\n
^ here\n"}
Where is ansible trying to pull the local ip from and why can't it do so in docker?
BTW I have installed net-tools in my docker container and it has an eth0 ip.
On virtualbox and in docker I have a line in /etc/hosts
ansible-master 127.0.1.1
UPDATE:
I run
ansible all --connection=local -m setup | less
on virtualbox ubuntu and Docker ubuntu.
On Virtualbox I get a lot of network-related info that I don't get on Docker:
"ansible_facts": {
"ansible_all_ipv4_addresses": [
<ip>,
<another ip>
],
"ansible_all_ipv6_addresses": [
<ipv6>,
<another ipv6>
],
Also in virtualbox I get
"ansible_default_ipv4": {
"address": <value>,
"alias": <value>,
"broadcast": <value>,
"gateway": <value>,
"interface": <value>,
"macaddress": <value>,
"mtu": <value>,
"netmask": <value>,
"network": <value>,
"type": <value>
},
None of this appears in Docker.
I have had a similar problem with fedora; the solution was to install the package that provides the 'ip' command (which is used to generate the fact your looking for). in the case of fedora 'dnf install iproute'.
For Ubuntu, you have to install the iproute2 package in your pre_tasks. Don't forget to gather facts again in another task with - setup: afterwards.
Use hostname flag to put your local container hostname in /etc/hosts:
docker run --hostname=my_hostname

Cannot install docker on OS X Version 10.9.5

I first tried installing VirtualBox by downloading "VirtualBox 5.0 for OS X hosts (amd64)" from the VirtualBox download page, and then installed boot2docker and docker via brew.
The first apparent issue appeared when creating the boot2docker-vm image:
$ boot2docker init
2015/07/27 21:38:13 Creating VM boot2docker-vm...
2015/07/27 21:38:13 Apply interim patch to VM boot2docker-vm (https://www.virtualbox.org/ticket/12748)
2015/07/27 21:38:13 Failed to modify VM "boot2docker-vm": exit status 1
Launching the VirtualBox manager application I can see the boot2docker-vm machine "Running", but looking at the log I see something like this which appears to indicate that the boot2docker-vm "machine" failed to boot:
00:00:04.169546 Guest Log: BIOS: Boot : bseqnr=1, bootseq=4231
00:00:04.169711 Guest Log: BIOS: Boot from Floppy 0 failed
00:00:04.170101 Guest Log: BIOS: Boot : bseqnr=2, bootseq=0423
00:00:04.170490 Guest Log: BIOS: CDROM boot failure code : 0002
00:00:04.170800 Guest Log: BIOS: Boot from CD-ROM failed
00:00:04.171190 Guest Log: BIOS: Boot : bseqnr=3, bootseq=0042
00:00:04.171795 Guest Log: int13_harddisk: function 02, unmapped device for ELDL=80
00:00:04.172304 Guest Log: BIOS: Boot from Hard Disk 0 failed
00:00:04.172706 Guest Log: BIOS: Boot : bseqnr=4, bootseq=0004
00:00:04.172991 Guest Log: BIOS: Booting from LAN...
00:00:04.191271 Display::handleDisplayResize(): uScreenId = 0, pvVRAM=0000000000000000 w=720 h=400 bpp=0 cbLine=0x0, flags=0x1
00:00:06.446949 Guest Log: BIOS: Boot from LAN failed
00:00:06.448852 Guest Log: Could not read from the boot medium! System halted.
I uninstalled everything and then tried downloading and installing from boot2docker download page, which installs VirtualBox, boot2docker, and docker all in one go. But I still see the same problem indicated above (the boot2docker-vm machine fails to boot).
I'm reluctant to make big changes to the OS X version on my laptop, since my hardware is old. But I'll try the installation sequence on a more modern machine and see if it works there.
Has anyone managed to make docker work on OS X Version 10.9.5?
EDIT (adding additional information which comments suggest might be relevant):
My machine has:
2.26GHz Intel Core 2 Duo
4Gb of RAM (1067 MHz DDR3)
NVIDIA GeForce 9400M 256 MB
OS X 10.9.5
I installed everything as the primary User (not root) on my system.
And the versions of everything which I installed are:
VirtualBox 4.3.30 r101610
boot2docker version 1.7.1
docker version 1.7.1
This issue on github might be of help (Latest version of virtual box 4.3.x works fine in the issue described). Though I would suggest to use docker-machine. Below are the steps (Installation):
$ docker-machine create --driver virtualbox dev
$ eval "$(docker-machine env dev)"
And then you can use docker commands as usual.
Some of the comments in the github issue suggested by nash_ag and this stackoverflow question pointed me in the right direction.
This is the sequence of steps I used to get VirtualBox, boot2docker, docker, and docker-machine working in my environment (where $USERNAME is my primary OS X User, who installed VirtualBox), with several wrong turns elided, and most output omitted:
$ rm -rf /Users/$USERNAME/VirtualBox\ VMs/
$ boot2docker delete
(ran VirtualBox Uninstall script from my desktop)
...
$ brew tap caskroom/cask
...
$ brew update
...
$ brew install brew-cask
...
$ brew cask install virtualbox
...
$ VBoxManage -v
5.0.0r101573
$ boot2docker -v
Boot2Docker-cli version: v1.7.1
Git commit: 8fdc6f5
$ VBoxManage list vms
(nothing)
$ boot2docker init -v
...
$ boot2docker up
...
$ eval "$(boot2docker shellinit)"
(writes .pem files)
$ brew install docker-machine
...
$ docker-machine -v
docker-machine version 0.3.1 (HEAD)
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM
$ docker-machine create --driver virtualbox dev
...
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM
dev virtualbox Running tcp://192.168.99.100:2376
$ VBoxManage list vms
"boot2docker-vm" {99d5c5c1-e7cc-49bf-93c7-b0cbf626d62c}
"dev" {341fd11e-86f9-46ca-89e6-39ee78458a4b}
$ eval "$(docker-machine env dev)"
$ docker run -d -p 8000:80 nginx
...
$ curl $(docker-machine ip dev):8000
<!DOCTYPE html>
...
At this point things appear to be working well enough for me to use the "standard" docs/instructions for docker and docker-machine, so my original problem is solved.

Resources