Switch docker daemon from minikube back to docker desktop - docker

I recently changed the docker daemon from my local Docker Desktop to local minikube following these instructions.
#FOR /f "tokens=*" %i IN ('minikube -p minikube docker-env --shell cmd') DO #%i
After running some tests, I want to change it back to my previous setup. I already tried to change some environment variable but it did not succeeded.
SET DOCKER_HOST=tcp://127.0.0.1:2375

Run the below command to get the list of Docker Hosts..
docker context ls
output will be something like below
NAME DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
default * Current DOCKER_HOST based configuration unix:///var/run/docker.sock swarm
desktop-linux unix:///home/sc2302/.docker/desktop/docker.sock
rootless Rootless mode unix:///run/user/1001/docker.sock
Now, from the output's, select the context you want to use.. ex: to switch to default context
docker context use default

Related

Need help to point docker client to the docker daemon running on my laptop

I am running minikube on my Macbook. in order to build a Dockerfile inside minikube (VM), I pointed my docker client to the minukubeĀ“s docker daemon using below command
eval $(minikube docker-env)
I was able to build the image successfully on minikube and I stopped the minikube when my job is done.
Now when I tried to run the command "docker images" I am getting below error
"Cannot connect to the Docker daemon at tcp://:. Is the docker daemon running?"
I would really appreciate any help to resolve this problem
Note : I figured it just lasts on the current session of the terminal. but still wondering is there any better way w/o closing the current session of the terminal
If you look at the Minikube documentation on the docker-env command here, or run the command with the --help flag like so:
$ minikube docker-env --help
Sets up docker env variables; similar to '$(docker-machine env)'.
Options:
--no-proxy=false: Add machine IP to NO_PROXY environment variable
--shell='': Force environment to be configured for a specified shell: [fish, cmd, powershell, tcsh, bash, zsh],
default is auto-detect
-u, --unset=false: Unset variables instead of setting them
Usage:
minikube docker-env [flags] [options]
Use "minikube docker-env options" for a list of global command-line options (applies to all commands).
you'll notice the --unset flag.
Try running:
$ eval $(minikube docker-env --unset)
Docker for Mac does not use a tcp connection to the daemon, but connects using a socket (/var/run/docker.sock); check if there's no DOCKER_HOST environment variable set in your shell that overrides the default connection.
It seems minikube overrides the default docker settings by setting these three variables
DOCKER_HOST=
DOCKER_TLS_VERIFY=1
DOCKER_CERT_PATH=/some/certs
Please unset these and stopped minikube stop and that and docker for mac will start working.
eval "$(docker-machine env -u)"
It will unset the DOCKER_* variables.
For the record, here's the output of docker-machine env -u:
unset DOCKER_TLS_VERIFY
unset DOCKER_HOST
unset DOCKER_CERT_PATH
unset DOCKER_MACHINE_NAME
More information you can find here: docker-mac, docker-unset.

Difference between running eval and docker before $(docker-machine ...)

As the title says, whats the difference between running a command for a docker-machine as
eval $(docker-machine env mycontainer)
docker run httpd
And
docker $(docker-machine config mycontainer) run httpd
as both create an httpd image under the "mycontainer" ip, but with the second, there's no container shown with "docker ps"
In the first form, you are first evaluating a series of env vars (DOCKER_HOST, DOCKER_CERT_PATH, DOCKER_TLS_VERIFY, DOCKER_MACHINE_NAME) which are configuring your current shell so that any docker command you later launch will talk to the same docker daemon.
In the second form, you are passing the params (--tlsverify, --tlscacert, --tlscert, --tlskey, -H) directly to the docker command. Those will eventually override the values already in your env or the defaults (i.e. connect to local daemon).
In this latest case if you want to see the container you just launched making sure your are talking to the correct server, you have to use the same command line parameters again with docker $(docker-machine config mycontainer) ps
To summarize:
config is more suited for single on-spot commands
env is more convenient for a full session on the same server.

Docker daemon (not containers) can't read environment variables

Trying to configure a container running outside of GCP to log to Google Cloud Platform (StackDriver). One requirement is that the Docker daemon is able to locate the environment variable GOOGLE_APPLICATION_CREDENTIALS so it can authenticate. One would assume that the following would work, but it doesn't:
GOOGLE_APPLICATION_CREDENTIALS=/usr/local/keys/project-1.json docker run --log-driver=gcplogs ...
That outputs:
ERROR: for api Cannot start service api:
failed to initialize logging driver: google: could not find default credentials.
See https://developers.google.com/accounts/docs/application-default-credentials
for more information.
Haven't found any documentation on how to set that directly on daemon.json, but I don't want that either because I might have different containers logging to different GCP projects.
I've tried this on Mac (docker desktop) and Debian.
This is question that keeps coming back. What is happening here is that environment variable GOOGLE_APPLICATION_CREDENTIALS is loaded by the system docker daemon. System daemons don't see the environment variables set in the user login. What you need to do is set the GOOGLE_APPLICATION_CREDENTIALS at the system level.
Here is how to do that in Ubuntu(Systemd):
$ sudo mkdir -p /etc/systemd/system/docker.service.d
Create /etc/systemd/system/docker.service.d/env.conf with the following content:
[Service]
Environment="GOOGLE_APPLICATION_CREDENTIALS=/path/to/file.json"
Apply the changes.
$ sudo systemctl daemon-reload
Once done restart docker/containerd daemons
$ sudo systemctl restart containerd
$ sudo systemctl restart docker
Test the gcplogs driver
docker run --log-driver=gcplogs --log-opt gcp-project="my-project" hello-world

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
}

Can I pass --max-concurrent-downloads as a flag?

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
}

Resources