Skip to content

Instantly share code, notes, and snippets.

@ospatil
Last active October 18, 2020 15:55
Show Gist options
  • Save ospatil/0aee33bc49ea46970253dbff59946907 to your computer and use it in GitHub Desktop.
Save ospatil/0aee33bc49ea46970253dbff59946907 to your computer and use it in GitHub Desktop.
Handy reference working locally with docker, kubernetes and minikube

Docker misc

  • Running a docker image with port mapping - docker run --init -p 4444:4444 --rm <IMAGE_NAME>

    --init makes it respond to signals like ctrl+c

    -d will make it run in detached mode, so for stopping you'll have to do docker ps and use the container id.

Working with minikube and local images

By default, minikube tries to pull images from docker hub and produces ImagePullBackoff error if a local image is used.

Minikube uses its own docker daemon and not the Docker Desktop daemon. Therefore, the images created outside of minikube daemon are not available within its environment.

Here is how local images can be used in minikube:

  • Run the following command in shell: eval $(minikube docker-env).
  • Create the docker image using docker build command.
  • Set the ImagePullPolicy to Never for the pod or deployment using that image.
  • Reset the environment to use the docker desktop daemon using command: $(minikube docker-env -u)

Running local images in minikube environment

  • Ssh into minikube environment: minikube ssh
  • Run the image using docker run.
  • Ssh into the minikube environment from another shell and test the connectivity using curl.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment