How do YOU create your Docker images? - eviltoast

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?

  • AggressivelyPassive@feddit.de
    link
    fedilink
    English
    arrow-up
    5
    ·
    1 year ago

    Maybe you should read up a bit about how docker works, you seem to misunderstand a lot here.

    For example the “various images” are kind of the point of docker. Images are layered, and each layer is its own image, so you might end up with 3 or 4 images despite only building one image.

    This is something you can’t really prevent. It’s just how docker works.

    Anyway, you can mount the docker socket into a container, and using that socket you can then build an image within the running container. That’s essentially how most ci/cd systems work.

    You could maybe look into podman and buildah, as far as I know, these can build images without a running docker daemon. That might be a tad “cleaner”, but comes with other problems (like no caching).

    • 𝘋𝘪𝘳𝘬@lemmy.mlOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      I have no problem with Docker creating several images and containers and volumes for building a single-image application. The problem is that it does not clean up afterwards and leaves me with multiple things I don’t need for anything else.

      I also don’t care about caching or any “magic” stuff. I just ideally want to run one command (or script doing it for me) to build an image resulting in just this one image without any other traces left. … I just like a clean environment and the build process ideally being self-contained.

      But I’ll look into your suggestions, thanks!

      • AggressivelyPassive@feddit.de
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        I seriously don’t understand what leftovers you’re talking about.

        You essentially have a Dockerfile that describes how you want to build your image, you run docker build with the path of your Dockerfile and the path of the context, and the rest is completely up to you. Docker does not leave that many traces around - only the built images within docker itself, but as I said, that’s the point of building them.

        You can even export the image into a tar file and run docker prune afterwards, that should only leave the exported tar file.

        • 𝘋𝘪𝘳𝘬@lemmy.mlOP
          link
          fedilink
          English
          arrow-up
          1
          ·
          1 year ago

          When I built an image last time there were several unused other images with just hashes as names and two unused volumes, also multiple cache files and other files in the user’s home directory in various subfolders.