Moving local docker images to minikube (image persistency) - docker

Hey guys this is a quick question to see if it's possible to move the images stored on your local PC into minikube, without having to keep building them within minikube.
My Problem:
My problem is that everytime I restart my computer I would have to rebuild the images by using the eval $(minikube docker-env) command to connect my shell session to the minikube docker daemon. However, the images that you build on using your local daemon are persistent upon restart or shutdown. Is there a way to move these images into minikube so that the minikube docker daemon can pick them up, or else a way to pull those images straight from my local PC?

If you want to save your existing container back to an image (recommend using a new image name), run:
docker commit -p CONTAINER_ID NEW_IMAGE_NAME
You can then export the image into a tarball via:
docker save -o savedIMG.tar NEW_IMAGE_NAME
Determine the IP address of the Minikube container via: "minikube ip". It will likely be 192.168.49.2. Your host machine will be 192.168.49.1.
You then connect to the Minikube container via "minikube ssh" and scp the tarball from your host server. Example:
scp bob#192.168.49.1:/home/bob/savedIMG.tar .
(Note the space+period at the end)
You then import the image from the tarball via:
docker load --input savedIMG.tar

Related

How to push docker images with the associated containers

I have a docker container in a virtual machines where I am hosting my Postgres database, but when I pull that image to my local machine the container does not show up. I have tried import/export and save/load but still I can't get the container to show in my local machine. Any help will be much appreciated!
You have to build containers after pulling in the images.
The simplest way is
docker create --name my_container bf141206f773
where bf141206f773 is the image's hash. You can also use its full_name:tag.
To start your new container:
docker start my_container
To enter your new container:
docker exec -it my_container /bin/bash
If you want to see how I do this in a deployment-environment, check out my Laravel QuickStart project's docker files: https://github.com/phpexpertsinc/laravel_quickstart

Running a bitcoind docker

Thanks to the bitcoin.stack community I have successfully launched a bitcoind docker with an external volume which has the block data
Currently its in 100% sync but I am facing an issue to get information using bitcoin-cli I need to run bitcoind -reindex and then add txindex=1 into bitcoin.conf
As I pulled the docker image from docker hub I do not have any control over its docker file and I have 140GB+ blockchain data that I do not wanna discard and start over
How do I run --reindex on an docker container ?
While your container is running you can run docker exec -it <mybitcoindcontainer> /bin/sh. This should give you a shell inside your running container. You can then run your choice of commands at the shell prompt.

Jenkins not getting launched after docker start

I started my Jenkins Docker image that I had saved earlier.
docker start -ai <my_container_ID>
I can see that jenkins has started in console but it doesn't get launched:
screenshot
For the first time, I had started it using docker run command after which Jenkins got launched on browser and I also added some jobs in it and did docker commit.
Any help would be appreciated!
From your comments I see that you started a new container from jenkins image, made some changes and then did docker commit for creating a new image based on that.
In order to run a new container from that image you need to use docker run using the image's hash return by the docker commit command. Example:
$ docker commit cc79f8ec407d #hash of the container you want to commit
sha256:227efd2e30a9033e6ce288084c6452aa5a5112974ea833b559429a9ae78697a8 # new image hash return by docker commit
$ docker run 227efd2e30a9033e6ce288084c6452aa5a5112974ea833b559429a9ae78697a8 # hash of the new image
But bare in mind that when you run this new container from that image jenkins might not consider it as a new installation because the initialization process was already done before the commiting.
The easiest way to do that is to just point your browser to the IP address of your new Virtual Machine Docker host.
You could monkey around with ifconfig or ipconfig to figure it out, but thankfully Docker Toolbox comes with a handy command line option by utilizing docker-machine:
docker-machine ip default
That’s the IP of your host and where your web services will be listening! Granted this IP is on your local machine and not externally reachable. If you want outside services to hit your machine, you’ll need to set up port forwarding.
Now try docker run -p 8080:8080 --name=jenkins-master jenkins

kubectl run-ing a tarball'd image

I am trying to run a Nix-built Docker image in tarball form. With docker, docker load -i <path> followed by a docker run works fine. Now I've uploaded the tarball to Artifactory and am trying to run the image on K8s with something like:
$ kubectl run foo-service --image=<internal Artifactory>/foo-service/foo-service-latest.tar.gz
However all I see is:
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
foo-service 1 1 1 0 2h
Is it possible to load an image from a (remote) tarball in K8s? If yes, what is the command to do so?
There is no way to do that directly in Kubernetes.
You can do docker load and then docker push to a registry (you can host a private registry in Kubernetes or use a public one) and after that kubectl run.
Minikube also has a registry addon for local development.

Docker: save internal hd contents

is there a way to save the contents of a container's "internal" HD. I have tried to use the docker commit but when I shut down the container and turn it on again, the contents that I have downloaded or generated inside the container (logs, etc) are gone.
When you start the container back up do you use docker start or docker run?
docker run -i -t docker/image /bin/bash will start a NEW container with the information from the original imagefile.
docker start {dockercontainerID} will restart a previously running container. you can get a list of previous dockers with docker ps -a
If you have save a docker with docker commit {runningdocker} docker/image2 you will use the new image name. ie `docker run -ti docker/image2 /bin/bash

Resources