Maybe somebody knows how to restart a daemon (which is running as a systemd service) from the docker container? I developed a python script to do that and built an image using a simple Dockerfile:
FROM python:3.8 ADD my-script.py . CMD [ "python3", "./my-script.py" ]
and container built using docker-compose:
version: '2.4' services: my-script: image: my-script-image:latest container_name: my-script restart: unless-stopped networks: - network logging: driver: json-file options: max-size: "50m" max-file: "10" networks: network: driver: "bridge" driver_opts: com.docker.network.bridge.name: <NETWORK-NAME>
Should I describe any specific user in my Dockerfile? When I execute a script from the command line (RHEL8) - everything works fine, it can restart the daemon (but only if you use the ‘root’ user), but when a script is running inside a container - it doesn’t work (while ‘docker logs --tail’ show that everything works fine, but daemon doesn’t restart).