Is it possible to use containers as virtual machines?

I wonder:
Is it possible to use containers as virtual machines?

At moment I’m building a small home server and I wanted to create two virtual machines on it: one for the installation of Nextcloud and and one for installing a separate PHP environment (for development purposes).

Is the same setup possible with containers? I mean: running a container with a RHEL filesystem and installing Nextcloud and/or a PHP environment inside of it?

The advantage of this would be that you don’t have the overhead of extra guest kernels.

Is it possible? Is this already being done?

Thanks in advance!

2 Likes

Hello @j.verhoeckx ,
There is a way to use VM images to create base container images, but I would point you to podman search php as a way to find if there are container images available like you are wanting. From that command I get “redhat.com registry.access.redhat.com/codeready-workspaces/stacks-php Red Hat CodeReady Workspaces- PHP Stack cont… 0” as one option (sorry for the truncated content). From that I would then do podman pull registry.access.redhat.com/codeready-workspaces/stacks-php and then podman images to find the image I just pulled. Thenpodman run -it --rm <image ID> /bin/bash and I am at a bash prompt of a code ready PHP stack in a container. --rm to have the container removed after exit, the image would still be there though.

1 Like

Nextcloud is a bit hostile with containers. Some features might not work. As for the development environments you can use containers effectively. You can use podman directly or use toolbox. If you like toolbox but would like to avoid sharing your home directory with the containers you can use tlbx which is a small bash tool similar to toolbox and can easily get you started with small modifications.

2 Likes

Thanks for the information! Seems really interesting!
I see the Red Hat Codeready image contains Apache and PHP but it’s unclear if it contains a database.

I pulled and run the image and I’m able the access it. Now I only have one last question: on which IP address can I access the web server?

When I run

podman inspect -f '{{ .NetworkSettings.IPAddress }}' <container_name_or_container_id>

I do not get an IP address (the output is an empty line)?

Thanks! tlbx seem interesting!

Typically you would expose the port when you create the container with the -p option:

-p <host port>:<container port>

Then you would point your browser to the IP address of the host system and port.

1 Like

I think it would be localhost:8080

1 Like

I tried this but it didn’t work.

Okay, I didn’t now that.

I realize that I don’t know enough about containers so I will keep using virtual machines for the server that I’m building. As @lispydobby points out, a virtual machine is also a better fit for Nextcloud. For the development environment I will create a second virtual machine.

Thanks everybody for thinking along!

If you have Fedora up and running, I’d highly recommend reading up on Fedora Magazine about using Podman. It’s pretty great and not too difficult to learn. Here are a few articles I’d recommend to get started with:

Once you’ve deployed a container and then removed it a few times, you’ll get pretty comfortable and doing the stuff you would like to do like deploying NextCloud or have a development environment will come easy.

1 Like

Hello @alph4num3ric,

What you describe seems really interesting and tempting! The tutorials you mention seem easy to follow.

A few questions:

  • Lispy Dobby writes that Nextcloud is a bit hostile with containers and that some features might not work. Do you think I could install Nextcloud groupware / LibreOffice Online / Nextcloud Talk inside the Nextcloud container?
  • I just installed Red Hat Enterprise Linux 8.4 and Cockpit on a small server (an Intel NUC). Maybe I can create the same setup as mentioned in the article ‘Installing Nextcloud 20 on Fedora Linux with Podman’ with Cockpit (Cockpit has a Podman application)? Of course I could always use the command-line.

The benefit of using contains / Podman would be that it’s probably much more efficient than using virtual machines (and you don’t have to install RHEL ever time).

Thanks for thinking along!!

Lispy Dobby writes that Nextcloud is a bit hostile with containers and that some features might not work. Do you think I could install Nextcloud groupware / LibreOffice Online / Nextcloud Talk inside the Nextcloud container?

Those will run fine for the most part. Once you have it running you can go to the “App” page and install them. Depending on the image you use, there will be some errors about an optional library not being installed, and some apps might want some additional packages installed in the image. If this is the case and they’re important enough that you want them, you can build the image yourself.

I just installed Red Hat Enterprise Linux 8.4 and Cockpit on a small server (an Intel NUC). Maybe I can create the same setup as mentioned in the article ‘Installing Nextcloud 20 on Fedora Linux with Podman’ with Cockpit (Cockpit has a Podman application)? Of course I could always use the command-line.

This will work just fine. I have mine running on Fedora 34 on a dual core Intel Atom board with 4GB of RAM I bought in like 2009. RHEL 8.4 ships with podman 3 so it does everything you need it to do. For the most part, there’s only a few podman commands you need to get familiar with to get started:

  • This lets you manage the images you have store locally:

    podman image   ls | rm | pull
    
  • This lets you look up and manage your containers that have been created from the downloaded images:

    podman container   ls | ps | logs | start | stop | rm
    
  • To lookup and manage your volumes for persistent storage:

    podman volume   ls | create | remove
    
  • And to get more info about any of the above items there is inspect:

    podman inspect image | container | volume | network | pod
    
  • There’s also stuff for networks and pods too, but I’d recommend starting with the above. Inspect works with them as well:

    podman network
    podman pod
2 Likes

Thank you very much for this great summary :slight_smile: !

Hi @j.verhoeckx ,
Check out this blog [https://opensource.com/article/21/7/linux-podman?utm_medium=Email&utm_campaign=weekly&sc_cid=7013a000002wQ7wAAE](Run a Linux virtual machine in Podman | Opensource.com). Apparently Podman now has an additional capability, running and creating VM’s! Go podman machine! On Silverblue you would also need to layer Qemu I believe.

1 Like

Hi @jakfrost,

Thank you very much! Very interesting!! Podman is the future :slight_smile: !