Docker Images disappeared after WSL2 migration - image

After migrating Docker to the latest and enabling WSL2 engine, all images have disappeared when I run:
C:\docker images --all
REPOSITORY TAG IMAGE ID CREATED SIZE
I need to recover my previous images.
Thanks for your help in advance.

I needed to uncked "Use the WSL 2 based engine" then rerun my command to see that WSL 2 based engine had a different images directory.
I have exported my old images and imported them after enabling WSL2 again.

Related

How can I write a Dockerfile to merge two or more docker images into one?

I am trying to integrate three things into one docker image.
The first image is: https://github.com/opencv/gst-video-analytics
The second image is: https://github.com/domoritz/streamlit-docker
The third image is: http://blog.feabhas.com/2020/02/running-the-eclipse-mosquitto-mqtt-broker-in-a-docker-container/
Can someone guide me on how can I integrate these three images into one on docker in Windows 10?
Operating system: Windows 10
Docker version 19.03.1
I did something similar with docker-combos. You basically just include all the lines from all three Dockerfile files, but only one FROM line. Then start correcting errors as they come up. You may have a bunch of errors because the FROM lines aren't the same (one is Ubuntu, one is Alpine so you have to change apk add to apt-get install).
You can also consider not using a single Docker container for all these and go with docker-compose. It lets you bring up multiple containers all together and link their network for easy access.

Dockerfile vs create image from container

Is there some difference between creating image using Dockerfile vs Creating image from container? (e.g. run a container from the same base as Dockerfile, transfer isntaller to the container, run them from command line and then create image from container).
At least I found out that installing VC Runtime from Windows Base docker container does not work :(
If you create an image using a Dockerfile, it's all but trivial to update the image by checking it out from source control, updating the tag on a base image or docker pulling a newer version of it, and re-running docker build.
If you create an image by running docker commit, and you discover in a year that there's a critical security vulnerability in the base Linux distribution and you need to stop using it immediately, you need to remember what it was you did a year ago to build the image and exactly what steps you did to repeat them, and you'd better hope you do them exactly the same way again. Oh, if only you had written down in a text file what base image you started FROM, what files you had to COPY in, and then what commands you need to RUN to set up the application in the image...
In short, writing a Dockerfile, committing it to source control, and running docker build is almost always vastly better practice than running docker commit. You can set up a continuous-integration system to rebuild the image whenever your source code changes; when there is that security vulnerability it's trivial to bump the FROM line to a newer base image and rebuild.

How to build Docker image own image

Currently I'm doing POC in docker for Windows 2016. I just want to know how to build an own image.
Currently we are using
docker pull microsoft/windowsservercore
to pull base image but due to security reason we should not download images from public repository. So we should build our own Windows images.
Is it possible to build our own image with out downloading? If yes, means how we can build our own Windows server images.
There are plenty of ways to build a base image you can use tar or scratch
Below is the example:
FROM scratch
ADD helloworld.sh /usr/local/bin/hellowworld.sh
CMD ["/usr/local/bin/helloworld.sh"]
see the link to get more information
I think you've to setup your own company docker registry. After setting it up you can "import" the windowsservercore image to the private registry. See this link for further explanation.
You can use one downloaded image as the base image and then customize that image as per your needs. You should refer to Dockerfile for information regarding configuring your own image.

How to get an access to Magento App code which is in Docker container

I haven't managed to find the solution how to get an access to Magento App code, which is in Docker container, at my host machine to have a chance to develop in my favorite IDE.
In detail, I use this image (https://github.com/alexcheng1982/docker-magento) to get Magento 1.9.
I built containers by the command "docker-compose up -d" and everything is fine. I can see my site that works fine at http://local.magento .
But, as a developer I want to open the app in PHPStorm editor on my host machine. How to do it?
Thanks in advance.
You have to add a volume
volumes:
- ./src/:/var/www/html
Data will be added in local src folder.

Can Docker Autonomously Restart Containers and Commit Changes with New Image Tag?

I am using Docker for my deployment and as it stands I use Docker-Compose (.yml file) to launch ~6 containers simultaneously. Each image within the Compose file is locally found (no internet connection within deployment environment).
As it stands the steps my deployment takes are as follows:
Run docker-compose up (launches 6 containers from local images such as image1:latest, image2:latest, etc. using the images with the "latest" tag)
When exited/stopped, I have 6 stopped containers. Manually restart each of the six stopped containers (docker start xxx)
Manually commit each re-started container (docker commit xxx)
Manually re-tag each of the previous generation images incrementally (image1:latest -> image1:version1, image1:version2, etc.) and manually delete the image containing the "latest" tag
Manually tag each of the committed containers (which are now images) with the "latest" tag (image1:latest)
This process is rather user-involved and our deployment requires the user involvement to only be run the "docker-compose up" command then shutting down/stopping Docker-Compose.
The required end goal is to have a script, or Docker, take care of these steps by itself and end up with different generations of images (image1:version1, image1:version2, image1:latest, etc.).
So, my question is, how would I go about creating a script (or have Docker do it) where the script (or Docker) can autonomously:
Restart the stopped containers upon stopping/exiting of Docker-Compose
Commit the restarted containers
Re-tag the previous images with latest tags to an incremented version# (image1:version1, image1:version2, etc.) then delete the previous image1:latest image
Tag the newly committed restarted containers (which are now images) with the "latest" tag
This is a rather lengthy and intensive question to answer, but I would appreciate any help with any of the steps required to accomplish my task. Thank you.
The watchtower project tries to address this.
https://github.com/CenturyLinkLabs/watchtower
It auto restarts a running container when a base image is updated.
It is also intelligent so, for example, when in needs to restart a container that is linked to other containers, it does so without destroying the links.
I've never tried it but worth a shot!
Let us know how it goes. I'm gonna favourite this question as it sounds a great idea.
PS If watchtower proves a pain and you try to do this manually then ...
docker inspect
is your friend since it gives you loads of info about containers and images. Allowing you to determine current status.

Resources