Currently I’m planning to dockerize some web applications but I didn’t find a reasonably easy way do create the images to be hosted in my repository so I can pull them on my server.

What I currently have is:

  1. A local computer with a directory where the application that I want to dockerize is located
  2. A “docker server” running Portainer without shell/ssh access
  3. A place where I can upload/host the Docker images and where I can pull the images from on the “Docker server”
  4. Basic knowledge on how to write the needed Dockerfile

What I now need is a sane way to build the images WITHOUT setting up a fully featured Docker environment on the local computer.

Ideally something where I can build the images and upload them but without that something “littering Docker-related files all over my system”.

Something like a VM that resets on every start maybe? So 
 build the image, upload to repository, close the terminal window, and forget that anything ever happened.

What is YOUR solution to create and upload Docker images in a clean and sane way?

2 points

I use portainer, and when I deploy an image, I write a short bash script for it.

  • stop the image if running
  • pull the image
  • run the image

This lets me easily do updates. I have a script for each image I run, it’s less than a dozen. They’re all from public repositories.

permalink
report
reply
3 points

VM with a docker build environment.

As for “littering”, a simple docker system prune -f after a build gets rid of most of it.

permalink
report
reply
2 points

I use podman, and the standalone tool “buildah” can build images from dockerfiles, and the tool “skopeo” can upload it to an image repository.

permalink
report
reply
10 points
*

For the littering part, just type crontab -e and add the following line:

@daily docker system prune -a -f
permalink
report
reply
1 point
*

as a user with root permission or as root ?

permalink
report
parent
reply
8 points
*

You shouldn’t need sudo to run docker, just can create a docker group and add your user to it. This will give you the steps on how to run docker without sudo.

Edit: as pointed out below, please make sure that you’re comfortable with giving these permissions to the user you’re adding to the docker group.

permalink
report
parent
reply
3 points

run docker without sudo.

Doing that, you effectively give the user account root access without password

docker run --volume /etc:/host_etc debian /bin/bash -> can read/write anything below the host’s /etc directory, including shadow file, etc.

permalink
report
parent
reply
2 points
*

Careful this will also delete your unused volumes (not attached to a running container because it is stopped for whatever reason counts as unused). For this reason alone, always use bind mounts for volumes you care about.

permalink
report
parent
reply
1 point

Yes.

All my self hosted containers are bound to some volume (since they require reading settings or databases).

permalink
report
parent
reply
-1 points
*

permalink
report
parent
reply
3 points
*

Genuinely curious, what would the advantages be?

Also, what if the Linux distro does not have systemd?

permalink
report
parent
reply
1 point

I was just making a meme dude. Personally, I like systemd, it’s more complicated to learn, I ended up reading books to really learn it properly. There’s 100% nothing wrong with cron.

One of the reasons I like timers is journalctl integration. I can see everything in one place. Small thing.

permalink
report
parent
reply
1 point

The chances I am going to manage a linux distro without systemd are low, but some systems (arch for example) don’t have cron out of the box.

Not that big of a deal since it’s easy to translate them all, but that’s one of the reasons why I default to systemd/timer units.

permalink
report
parent
reply
6 points
*

I build, configure, and deploy them with nix flakes for maximum reproducibility. It’s the way you should be doing it for archival purposes. With this tech, you can rebuild any docker image identically to today’s in 100 years.

https://youtu.be/0uixRE8xlbY?si=NIIFyzRhXDmcU8Kh

and here’s a link to a blog post, showing how to create a docker image and rust dev environment.

https://johns.codes/blog/rust-enviorment-and-docker-build-with-nix-flakes

permalink
report
reply
3 points

I knew you were going to mention nix before reading you post.

permalink
report
parent
reply
3 points
*

::Robert Redford nodding gif::

permalink
report
parent
reply

Selfhosted

!selfhosted@lemmy.world

Create post

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don’t control.

Rules:

  1. Be civil: we’re here to support and learn from one another. Insults won’t be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it’s not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don’t duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

Community stats

  • 5.3K

    Monthly active users

  • 3.7K

    Posts

  • 81K

    Comments