microsoft / microsoft/vscode-remote-release

Podman: systemd not working

Open
#6,396 10 comments 1 reaction 1 assignee View on GitHub

@chrmarti is already working on this.

Since Feb 28, 2022.

bug containers podman
Dominant language
Dockerfile
Stars
4.2k
Forks
470
Avg merge
1d 1h
Merged PRs (30d)
1

Description

Issue Type: Bug

Hi,

on my Ubuntu laptop I'm failing to create a working container (Centos8 +Apache+PHP+systemd) with the Remote-Containers extension. I use podman 3.2.1 and the following Dockerfile:

FROM quay.io/centos/centos:stream8
ENV container podman
# Remove unnecessary units
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ "/sys/fs/cgroup" ]
# Add user to run in the container
RUN adduser vscode
# Add some useful tools
RUN dnf -y install procps less
# Install Apache
RUN dnf -y install httpd httpd-tools
# Install PHP
RUN dnf -y install php php-bcmath php-cli php-common php-gd php-intl php-json php-ldap php-mbstring \
    php-mysqlnd php-pdo php-pear php-soap php-xml php-xmlrpc php-pecl-zip
RUN dnf clean all
# Update Apache Configuration
RUN sed -E -i -e '/<Directory "\/var\/www\/html">/,/<\/Directory>/s/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf
RUN sed -E -i -e 's/DirectoryIndex (.*)$/DirectoryIndex index.php \1/g' /etc/httpd/conf/httpd.conf
# Update php-fpm Configuration
RUN sed -E -i -e 's/;listen.owner = nobody/listen.owner = apache/g' /etc/php-fpm.d/www.conf
RUN sed -E -i -e 's/;listen.group = nobody/listen.group = apache/g' /etc/php-fpm.d/www.conf
RUN sed -E -i -e 's/listen.acl_users = (.*)$/;listen.acl_users = \1/g' /etc/php-fpm.d/www.conf
RUN systemctl enable httpd.service
EXPOSE 80
CMD ["/usr/sbin/init"]

When the container is created from the CLI it works just fine and I can see my website at localhost:4000. The container is created with:

$ podman run -it -p 4000:80 --name centosapache --tmpfs /run -v /sys/fs/cgroup/:/sys/fs/cgroup:ro -v /home/vicent/MyBlog/dst/:/var/www/html cf39dcb946b4
But when I create the container in VSCode using Remote-Containers extension, using the same Dockerfile I can see nothing at localhost:4000. My devcontainer.json is:

// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.217.4/containers/docker-existing-dockerfile
{
	"name": "Existing Dockerfile",

	// Sets the run context to one level up instead of the .devcontainer folder.
	"context": "..",

	// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
	"dockerFile": "../Dockerfile",

	// Set *default* container specific settings.json values on container create.
	"settings": {},
	
	// Add the IDs of extensions you want installed when the container is created.
	"extensions": [],

	// Use 'forwardPorts' to make a list of ports inside the container available locally.
	// "forwardPorts": [],

	// Uncomment the next line to run commands after the container is created - for example installing curl.
	// "postCreateCommand": "apt-get update && apt-get install -y curl",
  
	// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
	// "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],

	// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
	// "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
	"mounts": [ 
    "source=/sys/fs/cgroup,target=/sys/fs/cgroup,readonly,type=bind",
    "source=/home/vicent/MyBlog/dst,target=/var/www/html,type=bind"
   ],

	// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
	"remoteUser": "vscode",

  "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,Z",
  "workspaceFolder": "/workspace",

  "runArgs": ["--init", "--systemd=true", "--userns=keep-id", "-p", "4000:80"],
  "containerUser": "vscode"
}

I get no errors when the container is created but in the VSCode Terminal I can see:

[vscode@b76bc8b3b28e workspace]$ systemctl status httpd
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

I've tried to add/remove systemd related option to runArgs with no luck.

How can I fix this problem?

TIA

Extension version: 0.217.4
VS Code version: Code 1.64.2 (f80445acd5a3dadef24aa209168452a3d97cc326, 2022-02-09T22:02:29.527Z)
OS version: Linux x64 5.13.0-30-generic snap
Restricted Mode: No
Remote OS version: Linux x64 5.13.0-30-generic

System Info
Item Value
CPUs Intel(R) Core(TM) i5-10300H CPU @ 2.50GHz (8 x 2500)
GPU Status 2d_canvas: unavailable_software
gpu_compositing: disabled_software
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: disabled_off
rasterization: disabled_software
skia_renderer: enabled_on
video_decode: disabled_software
vulkan: disabled_off
webgl: unavailable_software
webgl2: unavailable_software
Load (avg) 1, 1, 1
Memory (System) 31.16GB (22.10GB free)
Process Argv --no-sandbox --force-user-env --unity-launch --crash-reporter-id 3937748a-de1b-41c3-be4b-7a31c73e6884
Screen Reader no
VM 0%
DESKTOP_SESSION ubuntu-xorg
XDG_CURRENT_DESKTOP Unity
XDG_SESSION_DESKTOP ubuntu-xorg
XDG_SESSION_TYPE x11
Item Value
Remote Dev Container: Existing Dockerfile
OS Linux x64 5.13.0-30-generic
CPUs Intel(R) Core(TM) i5-10300H CPU @ 2.50GHz (8 x 2500)
Memory (System) 31.16GB (22.11GB free)
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
pythonvspyl392:30443607
pythontb:30283811
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
vscoreces:30442553
pythondataviewer:30285071
vscod805cf:30301675
pythonvspyt200:30340761
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
vsc1dst:30438360
pythonvs932:30410667
wslgetstarted:30433507
vsclayoutctrc:30437038
vsrem710cf:30416617
dsvsc009:30440023
pythonvspyt640:30442238
vsbas813:30436447
vscscmwlcmt:30438805
helix:30440343
vsnot107cf:30443615

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.