Running local docker image in Minikube - docker

I have set up Docker for Windows and minikube. Example listed here for (k8s.gcr.io/echoserver:1.10) works just fine:
https://kubernetes.io/docs/setup/learning-environment/minikube/.
However when I create simple .NET MVC app under c:\dev\helloworld and try to run in in Minikube I get status: CrashLoopBackOff
Environment: Windows 10 Enterprise
Please help. What do i need to set up to make this work?

If you target the Docker daemon running in the minikube VM when you run docker build instead of the Docker for Windows daemon running on the host, then the minikube Docker will have access to that image and subsequent kubectl run commands will work as desired. I'm not sure exactly which commands to run on Windows, but on a POSIX system like Macs or Linux you can run:
# make 'docker' commands use daemon in minikube
eval $(minikube docker-env)
# build image so that minikube Docker daemon has it
docker build -t hello-world:v1 .
# deploy to kubernetes
kubectl run hello-world --image=hello-world:v1 --port=8080
# unset DOCKER environment variables so it goes back to
# targetting the usual Docker for Windows
eval $(minikube docker-env -u)
I don't know if eval is the right thing to run on Windows, but if you just run minikube docker-env it will likely give you some instructions, e.g. for me it gives:
$ minikube docker-env
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.103:2376"
export DOCKER_CERT_PATH="/Users/amitgupta/.minikube/certs"
# Run this command to configure your shell:
# eval $(minikube docker-env)

Related

Docker on Ubuntu inside WSL

I want to play with hyperledger fabric and this require to have linux.
Right now I want to use Windows and my idea was to install Ubuntu with WSL and just develop inside it.
The problem apear when I want to use docker.
I follow the steps in this tutorial step by step but I run into some problem.
filip#CSGN044D:~$ docker --version
Docker version 19.03.5, build 633a0ea838
filip#CSGN044D:~$ docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
filip#CSGN044D:~$ sudo service docker start
* Starting Docker: docker
and again...
filip#CSGN044D:~$ docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
Is this even possible ?
Looks like your Docker CLI is still trying to connect to the local Unix socket instead of localhost. Make sure your DOCKER_HOST environment variable is set to tcp://localhost:2375
Try by setting it in your shell first
export DOCKER_HOST=tcp://localhost:2375
Sanity check
echo $DOCKER_HOST
Now try running all your regular Docker commands. If those work, add this to your .bashrc
echo "export DOCKER_HOST=tcp://localhost:2375" >> ~/.bashrc
source ~/.bashrc
Not that in the tutorial the author uses localhost:2375 instead of tcp://localhost:2375. I think you have to explicitly specify the protocol. Also, your shell might not be using bash_profile as the config file (Usually Mac shells use that) so try adding it to your bashrc instead.

The docker host is currently not running

From Ubuntu 18.0.4 i am trying to run next command on terminal
eval $(minikube docker-env)
but unfortunately i got next message
and when i checked docker status i see it's running and active
Note:
I started minikube cluster using next command
minikube start -p ClusterName
not using
minikube start
any idea how i can solve this problem?
If you started your minikube instance with
minikube start -p ClusterName
Then you'll have to put the profile name for each command
minikube docker-env -p ClusterName
So you finally can run next command to get it work
> eval $(minikube docker-env -p YourClusterName)

Docker, Cannot connect to the Docker daemon. Is the docker daemon running on this host?

MacOS Sierra 10.12.2
Docker 1.12.5
New to Docker, this error appears every time I try to build a Docker file:
$ sudo docker build -t tutorial .
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
I followed the instructions from this SO post but the the problem wasn't solved:
Docker can't connect to docker daemon
Docker version:
$ docker --version
Docker version 1.12.5, build ...
The directory:
$ ls
Dockerfile README.md apache supervisord
Start virtual machine for Docker:
$ docker-machine start
Starting "default"...
Machine "default" is already running.
...
$ docker-machine env
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.00.00:2576" #edit
export DOCKER_CERT_PATH="/Users/myUser/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
# Run this command to configure your shell:
# eval $(docker-machine env)
...
$ eval "$(docker-machine env default)"
Run it again:
$ sudo docker build -t tutorial .
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
SOLVED: does works without sudo:
$ docker build -t tutorial .
Try run this command docker build -t tutorial . without sudo or run eval "$(docker-machine env default)" with sudo

docker-machine env default | eval "$(docker-machine env default)" | unable to run command docker

I've tried on Windows 10, windows 7 and Mac OSX, everything went well, but I am unable to run docker command after run docker-machine env default and eval "$(docker-machine env default)" I don't get any error messages.
$ docker-machine version
docker-machine version 0.8.2, build e18a919
env default
$ docker-machine env default
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.78.120:2376"
export DOCKER_CERT_PATH="/Users/elo/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
# Run this command to configure your shell:
# eval "$(docker-machine env default)"
connect to virtualbox machine
$ eval "$(docker-machine env default)"
then I run
$ docker
command not found: docker
I tried windows 10, windows 7 and Mac, just can't communicate with Virtualbox machine, so no docker command is found
I am able to ssh default
Is there anything I missed?
I tried windows 10, windows 7 and Mac, just can't communicate with Virtualbox machine, so no docker command is found
This isn't your error.
Your error is that your shell cannot find the docker executable. Docker requires two pieces, the server daemon (which is running in docker-machine's VM) and the client.
Make sure you have installed the docker client and that it is available in your $PATH.
I think "docker-machine ssh default" will work fine here. By writing ssh you are creating a secure shell connection to your host and then you can talk to your host.

docker error: /var/run/docker.sock: no such file or directory

I am new to docker. I have a shell script that loads data into impala and I want a docker file that runs builds an image and run the container.
I am on mac, installed boot2docker and have the DOCKER_HOST env set up.
bash-3.2$ docker info
Containers: 0
Images: 0
Storage Driver: aufs
Root Dir: /mnt/sda1/var/lib/docker/aufs
Dirs: 0
Execution Driver: native-0.2
Kernel Version: 3.15.3-tinycore64
Debug mode (server): true
Debug mode (client): false
Fds: 10
Goroutines: 10
EventsListeners: 0
Init Path: /usr/local/bin/docker
Sockets: [unix:///var/run/docker.sock tcp://0.0.0.0:2375]
I am trying to just installed a pre-built image using:
sudo docker pull busybox
I get this error:
sudo docker pull busybox
2014/08/18 17:56:19 Post http:///var/run/docker.sock/images/create?fromImage=busybox&tag=: dial unix /var/run/docker.sock: no such file or directory
Is something wrong with my docker setup?
When I do a docker pull busybox, It pulls the image and download is complete.
bash-3.2$ docker pull busybox
Pulling repository busybox
a9eb17255234: Download complete
fd5373b3d938: Download complete
d200959a3e91: Download complete
37fca75d01ff: Download complete
511136ea3c5a: Download complete
42eed7f1bf2a: Download complete
c120b7cab0b0: Download complete
f06b02872d52: Download complete
120e218dd395: Download complete
1f5049b3536e: Download complete
bash-3.2$ docker run busybox /bin/echo Hello Doctor
Hello Doctor
Am I missing something?
You don't need to run any docker commands as sudo when you're using boot2docker as every command passed into the boot2docker VM runs as root by default.
You're seeing the error when you're running as sudo because sudo doesn't have the DOCKER_HOST env set, only your user does.
You can confirm this by doing a:
$ env
Then a
$ sudo env
And looking for DOCKER_HOST in each output.
As for having a docker file that runs your script, something like this might work for you:
Dockerfile
FROM busybox
# Copy your script into the docker image
ADD /path/to/your/script.sh /usr/local/bin/script.sh
# Run your script
CMD /usr/local/bin/script.sh
Then you can run:
docker build -t your-image-name:your-tag .
This will build your docker image, which you can see by doing a:
docker images
Then, to run your container, you can do a:
docker run your-image-name:your-tag
This run command will start a container from the image you created with your Dockerfile and your build command and then it will finish once your script.sh has finished executing.
You can quickly setup your environment using shellinit
At your command prompt execute:
$(boot2docker shellinit)
That will populate and export the environment variables and initialize other features.
docker pull will fail if docker service is not running. Make sure it is running by
:~$ ps aux | grep docker
root 18745 1.7 0.9 284104 13976 ? Ssl 21:19 0:01 /usr/bin/docker -d
If it is not running, you can start it by
sudo service docker start
For Ubuntu 15 and above use
sudo systemctl start docker
On my MAC when I start boot2docker-vm on the terminal using
boot2docker start
I see the following
To connect the Docker client to the Docker daemon, please set:
export DOCKER_CERT_PATH=<my things>
export DOCKER_TLS_VERIFY=1
export DOCKER_HOST=tcp://<ip>:2376
After setting these environment variables I was able to run the build without the problem.
Update [2016-04-28] If you are using a the recent versions of docker you can do
eval $(docker-machine env) will set the environment
(docker-machine env will print the export statements)
I also got this error. Though, I did not use boot2docker but just installed "plain" docker on Ubuntu (see https://docs.docker.com/installation/ubuntulinux/).
I got the error ("dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?") because the docker daemon was not running, yet.
On Ubuntu, you need to start the service:
sudo service docker start
See also http://blog.arungupta.me/resolve-dial-unix-docker-sock-error-techtip64
For boot2docker on Windows, after seeing:
FATA[0000] Get http:///var/run/docker.sock/v1.18/version:
dial unix /var/run/docker.sock: no such file or directory.
Are you trying to connect to a TLS-enabled daemon without TLS?
All I did was:
boot2docker start
boot2docker shellinit
That generated:
export DOCKER_CERT_PATH=C:\Users\vonc\.boot2docker\certs\boot2docker-vm
export DOCKER_TLS_VERIFY=1
export DOCKER_HOST=tcp://192.168.59.103:2376
Finally:
boot2docker ssh
And docker works again
In Linux, first of all execute sudo service docker start in terminal.
If you're using CentOS 7, and you've installed Docker via yum, don't forget to run:
$ sudo systemctl start docker
$ sudo systemctl enable docker
This will start the server, as well as re-start it automatically on boot.
To setup your environment and to keep it for the future sessions you can do:
echo 'export DOCKER_HOST="tcp://$(boot2docker ip 2>/dev/null):2375";' >> ~/.bashrc
Then:
source ~/.bashrc
And your environment will be setup in every session
The first /var/run/docker.sock refers to the same path in your boot2docker virtual machine. Correcly write for windows /var/run/docker.sock
You, maybe the not the OP, but someone may have a directory called /var/run/docker.sock/ already due to how many times you hack and slash to get things right with docker (especially noobs). Delete that directory and try again.
This helped me on my way to getting it to work on Centos 7.
I have installed the docker using offline method and post server restart docker is not running.
So, I executed the below command it worked for me!
/usr/bin/dockerd > /dev/null
run the following commands, OS = CentOS / RHLE / Amazon Linux, etc.
sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl status docker
chmod 777 /var/run/docker.sock

Resources