Unable to run eval $(minikube -p minikube docker-env) - docker

I am trying to run
$ eval $(minikube -p minikube docker-env)
To set my current shell to use minikube's docker daemon so I can locally build images and have them available to minikube.
However, when I run the above I get the following output in my terminal
$ eval $(minikube -p minikube docker-env)
bash: $'\E[31m╭──────────────────────────────────────────────────────────────────────────────────────────────────────────╮\E[0m': command not found
I can run minikube -p minikube docker-env fine and get the below output
minikube -p minikube docker-env
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://127.0.0.1:62037"
export DOCKER_CERT_PATH="/Users/random/.minikube/certs"
export MINIKUBE_ACTIVE_DOCKERD="minikube"
# To point your shell to minikube's docker-daemon, run:
# eval $(minikube -p minikube docker-env)
I am running this on a Mac if it makes any difference.

Related

Running docker commands on remote machine through ssh

I have two machines:
Ubuntu workstation running docker
Macbook with Mac OS
I want to be able to run docker commands from MacOS through ssh on my Ubuntu workstation.
Docker works fine when running commands on Ubuntu.
SSH works fine (key based with entity saved).
I've tried creating a context:
docker context create ubuntu --docker "host=ssh://myuser#192.168.1.100"
docker context use ubuntu
docker run -it alpine sh
and I get:
docker: Cannot connect to the Docker daemon at http://docker. Is the docker daemon running?.
the same error I get when trying to:
docker -H ssh://myuser#192.168.1.100 run -it alpine sh
Nothing from the solutions I've found seems to be helping.
PS: 192.168.1.100 is only for the question. When running commands I use real IP, which is correct and not colliding with anything. Dirrect SSH is working perfectly.
For your case you can use docker-machine:
Install:
base=https://github.com/docker/machine/releases/download/v0.16.0 &&
curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/tmp/docker-machine &&
sudo mv /tmp/docker-machine /usr/local/bin/docker-machine &&
chmod +x /usr/local/bin/docker-machine
Run/create:
docker-machine create \
--driver generic \
--generic-ip-address=put_here_ip_of_remote_docker \
--generic-ssh-key ~/.ssh/id_rsa \
vm_123
Check:
docker-machine ls
docker-machine ip vm_123
docker-machine inspect vm_123
Use:
docker-machine ssh vm_123
docker run -it alpine sh
exit
exit
eval $(docker-machine env -u)
Extra tips:
Also you can make vm_123 as the active docker machine via this command:
eval $(docker-machine env vm_123)
docker run -it alpine sh
exit
eval $(docker-machine env -u)
and unset docker machine vm_123 as active via this command:
eval $(docker-machine env -u)
https://docs.docker.com/machine/drivers/generic/
https://docs.docker.com/machine/examples/aws/
https://docs.docker.com/machine/install-machine/
https://docs.docker.com/machine/reference/ssh/
Is you sure that ip on your Ubuntu is 192.168.1.1 ?
Because I think that its your router ip :)
Can you post ip a from your Ubuntu, please ?

Running local docker image in Minikube

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)

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

How to use "Docker Quickstart Terminal" to start another docker-machine?

On my mac, when I start docker by running "Docker quickstart terminal", it will start the default docker machine.
I see in the start.sh of the docker quickstart terminal is:
#!/bin/bash
VM=default
DOCKER_MACHINE=/usr/local/bin/docker-machine
VBOXMANAGE=/Applications/VirtualBox.app/Contents/MacOS/VBoxManage
BLUE='\033[0;34m'
GREEN='\033[0;32m'
NC='\033[0m'
... more
How can I start another docker machine without modifying this shell file?
You simply can create a new docker machine:
docker-machine create -d virtualbox --virtualbox-memory 2048 --virtualbox-disk-size 204800 my_new_machine
(replace my_new_machine)
Then you can ssh to it:
docker-machine start my_new_container
eval $($DOCKER_MACHINE env my_new_container --shell=bash)
docker-machine ssh my_new_container

Resources