WSL equivalent for Linux

Gergely

It was a mere wsl command to import a Fedora cloud image to my Windows 10.

What is the equivalent of this when I use Linux as the base OS? VirtualBox is more difficult.

NotTheDr01ds

For another option on your Linux hosts, I would recommend Docker. Once you install Docker, you can quickly spin up new "containers" based on existing "images", similar to what you are doing with wsl --import and wsl -d <DistroName> with WSL on Windows.

Docker actually goes far beyond just OS images, since you can download and run many different applications/servers/programming languages with ease.

For instance:

docker pull opensuse/leap # pulls the latest image from the online Docker repository.
# ^^^ Not strictly necessary since the next command will load it from the repo if it isn't found locally
docker run -td --name opensuse opensuse/leap # Starts a container from the image running in daemon mode with a terminal
docker exec -it opensuse bash # Executes bash inside the running container with an interactive terminal

# Exit bash the image (CTRL+D)

# Cleanup
docker stop opensuse # Stops the container
docker rm opensuse # Removes the container
docker rmi opensuse/leap # Removes the image

One thing you need to be well aware of is that these containers themselves are always ephemeral. Any changes made to a container or files created in them will be lost when the container is stopped. To persist configuration, you create Dockerfiles. To persist files, you mount an external volume (which can be a directory on your host) when starting the container.

There's definitely some learning curve in figuring out the Docker options needed for your particular use-case, but once you get the basics down (such as those commands above), it's very easy to try out different images easily.

Bonus - You can install Docker into a WSL2 instance and have those benefits there as well. You'll find a lot of Docker images for things that you just can't load under WSL, even.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related