1

Is there any way to modify this docker-compose file so to be able to make a few commands to be executed after the Ubuntu instance boots up?

version: "2.1"
services:
  webtop:
    image: linuxserver/webtop:ubuntu-mate
    container_name: webtop
    security_opt:
      - seccomp:unconfined #optional
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Spain
      - SUBFOLDER=/ #optional
      - KEYBOARD=en-us-qwerty #optional
      - TITLE=Webtop #optional
    volumes:
      - /path/to/data:/config
      - /var/run/docker.sock:/var/run/docker.sock #optional
    ports:
      - 3000:3000
    devices:
      - /dev/dri:/dev/dri #optional
    shm_size: "1gb" #optional
    restart: unless-stopped

For example, I want apt update and apt upgrade to be executed after Ubuntu boots up.

Juan
  • 19
  • 2
  • This workflow sounds like you're describing a virtual-machine setup. If that's what you want – a full Linux distribution, with the ability to "boot up" and run init scripts and normal system administration tools – then use an actual virtual machine. In a typical Docker container setup you'd run `apt-get update` once during the image build process, and never after a container has started. – David Maze Oct 31 '22 at 13:51
  • Thank you very much for your answer. You are right about the commands always running during the build, so it would be better to say if there is a way to configure the webtop itself to run some commands on the OS it creates. Can such a thing be done? (Regarding using VM I don't want that because it would drain my resources) – Juan Oct 31 '22 at 14:04
  • A container is a wrapper around a _process_, not a full operating system. If you're trying to do all of the things a full OS does, it's unlikely that a Docker container will be lighter-weight than a VM, but it will be much harder to set up. – David Maze Oct 31 '22 at 15:08
  • Thanks for the suggestion. However, even the boot time of the vm is prohibitive for the case, and I cannot control it programmatically. It must be done with the webtop. So, if I understand correctly, according to what you know, I can't make the webtop run some commands on the operating system it creates. Right? – Juan Nov 02 '22 at 22:07

0 Answers0