I am new to Docker and MiniKube.
On my Windows laptop I have installed Docker Desktop and MiniKube.
I created two nodes in MiniKube and they are up and running.
I have been using Powershell with images and containers with Docker Desktop with no issues.
Now I realize that Minikube is using it's own installation of Docker and I cannot see the containers created by MiniKube in Powershell.
How do I get Powershell to point to Docker used by MiniKube?
How do I reverse that change to work again with Docker Desktop?
Related
I run a docker-compose (python) application on a remote machine, which I can access via SSH for remote development with VS Code.
I'm running the docker compose application on a Ubuntu 22.04 LTS machine and develop from a Windows 10 notebook. The remote machine has docker desktop 4.11 installed, as well as the Docker Extension Pack for VSC.
When I open the folder on the remote machineand start the application, I can see the that the docker images are created and containers are running. But when I try to attach a Visual Studio Code to the running container I get the error:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Is there a way to debug the code inside the docker containers?
Seems like the docker engine fo docker desktop is not found by the docker extension of VSC. Docker desktop for Linux is installs the docker engine in unix://home/<user/.docker/desktop/docker.sock and not under the standard docker engine path mentioned in the error messageunix://var/run/docker.sock. See Switch between Docker Desktop and Docker Engine
So my solution is to install the Docker Engine instead of Docker Desktop until a fix of VSC or the VSC Docker extension is available.
After attaching Visual Studio Code to the running container you can debug the application in the same way as on your do on your own machine.
I have just started working on k8s and I am doing some stuff locally,
I have a image created using docker desktop. Now, I want this image to be used within my minikube's VM environment. I want to create a deployment using kubectl create deployment hello-minikube --image=my_local_image_name. Going through docs, and as per my understanding, it tells us how docker desktop can be used to interact with the minikube's in-built docker demon.
Following the instructions,
Running docker images gives me images within minikube's docker.
But, in my case I want the other way around.
How can I do that ?
Secondly, as a add-on how can I store images within minikube's VM's docker ?
Docker Desktop and Docker from Minikube are two separate Docker Engines. That is why they don't share the Docker image registry.
So you have the following options:
Use Kubernetes from Docker Desktop instead of Minikube (Docker Desktop comes with Kubernetes cluster built-in).
Build your Docker image with Docker Engine from Minikube (instead of Docker Desktop).
Use external Docker registry (you can use Docker Hub or set up your own registry)
Running docker images gives me images within minikube's docker.
When you have this behaviour in your shell, rebuild your docker image.
It will use Docker from Minikube and store your image into Minikube's Docker registry
I installed minikube and now I want to create my docker containers, but how do I run the docker commands? I tried the following from command prompt
But it does not recognize docker as a command.
Also I tried from PowerShell with the same result, docker not recognized.
I currently only have minikube installed on my workstation because I was given the impression from comments to a previous question that I did not need Docker Desktop (see Unable to connect to running docker containers (minikube docker daemon))
In this SO question there is an answer that will show you 3 ways how to make Minikube and Docker work on Windows:
Scenarios are like this:
1) Use Docker, and minikube with Hyper-V (you will find instruction in
an answer above) Enable Hyper-V, install Docker, use minikube with
arguments minikube start --vm-driver hyperv --hyperv-virtual-switch
"<created Hyper-V switch name>" In the same time you will be able to
interact with Docker in normal way. Use kubectl/minikube commands for
your Kubernetes cluster and Docker commands for Docker. 2) Use
VirtualBox for Kubernetes and Docker toolbox for Docker minikube
start --vm-driver=virtualbox
3) Use Docker for Windows and Kubernetes in Docker
I believe this will solve your issue. Please, let me know if that helped.
I'm using Docker Desktop on Windows 10. For the purposes of development, I want to expose a local folder to a container. When running the container in Docker, I do this by specifying the volume flag (-v).
How do I achieve the same when running the container in Kubernetes?
You should use hostpath Volume type in your pod`s spec to mount a file or directory from the host node’s filesystem, where hostPath.path field should be of following format to accept Windows like paths:
/W/fooapp/influxdb
//W/fooapp/influxdb
/////W/fooapp/influxdb
Please check this github issue explaining peculiarities of Kubernetes Volumes on Windows.
I assume also that you have enabled Shared Drives feature in your Docker for Windows installation.
Using k8s 1.21.5 the following type of path worked for me:
/run/desktop/mnt/host/c/PATH/TO/FILE
Digging through this github issue helped me resolve which path to use:
https://github.com/kubernetes/kubernetes/issues/59876
The explanation is on the github link above.
The folder mount for /run/desktop/mnt/host/c does not exist on the distro you installed in WSL2 - on that WSL2 distro, the mount point to your C:\ drive is the more obvious /mnt/c.
Realize that Kubernetes and Docker are not installed in your installed WSL2 distro. Instead, Docker Desktop for Windows creates its own WSL2 VM called docker-desktop and installs Docker and Kubernetes on that VM. Then Docker Desktop for Windows installs the docker and kubectl CLIs on your WSL2 distro (and also on your Windows machine) and configures them all to point to the Docker and Kubernetes instances it created on the docker-desktop VM. This docker-desktop VM is hosting Docker and Kubernetes and also contains the /run/desktop/mnt/host/c mount point to your Windows C:\ drive and that can be used by your containers to persist data.
You can remote into the docker-desktop VM and see the /run/desktop/mnt/host/c mount point and folder structure by following the instructions (and discussion) at https://stackoverflow.com/a/62117039/11057678:
docker run -it --rm --privileged --pid=host justincormack/nsenter1
I am really confused, I had being learning kubernetes with minikube creating services and other things.
The problem comes in the following shape:
I run the following commands after a fresh install of minikube:
eval $(minikube docker-env)
The reason is because I want to get an image from my computer to be used with minikube. My understanding is that with this command I am in the same context for minikube and docker, so I can access my local images. "Please correct me if I am wrong here".
minikube start
So I get up and running the cluster, and ready to start creating things.
I want to pull the following container:
docker pull nginx/nginx-ingress
Because I want to try an ingress controller to work with my services.
But then I get this weird message:
Using default tag: latest
Warning: failed to get default registry endpoint from daemon (Cannot connect to the Docker daemon at tcp://192.168.99.101:2376. Is the docker daemon running?). Using system default: https://index.docker.io/v1/
Cannot connect to the Docker daemon at tcp://192.168.99.101:2376. Is the docker daemon running?
I run:
docker ps
And no results with a hang out.
I go to another terminal, I run the docker ps and it works like a charm.
Please if someone can bring some light to me of the impact of the command:
eval $(minikube docker-env)
And if you know why in my current Term with minikube running cannot access to my docker machine would help a lot.
minikube starts a dedicated virtual machine as a single-node Kubernetes cluster. If you have other Docker environments (a separate Docker Machine VM, the Docker Toolbox VM, the Docker for Mac or Docker for Windows environments, or a Linux-native Docker) these are separate from the Docker in the VM. You can't share images or containers between these environments.
If you have private images that aren't published to a registry, you'll have to re-docker build them when you switch to the Minikube environment. You otherwise don't specifically have to docker pull things that you're using, when you reference them in a Kubernetes pod spec Kubernetes will pull them for you.