Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFE: readthedocs container startup customization #10815

Closed
shahzebsiddiqui opened this issue Oct 11, 2023 · 3 comments
Closed

RFE: readthedocs container startup customization #10815

shahzebsiddiqui opened this issue Oct 11, 2023 · 3 comments

Comments

@shahzebsiddiqui
Copy link

shahzebsiddiqui commented Oct 11, 2023

What's the problem this feature will solve?

I am trying to setup a docker instance inside the readthedocs container build inorder to go about with running docker commands as part of the documentation build process

Describe the solution you'd like

I came across https://docs.readthedocs.io/en/stable/build-customization.html link which allows one to customize the build process. What i dont know is how i can set these settings in .readthedocs.yaml. The main thing i need is to be able to customize how docker is started i think i need --privileged option set when starting the container

Alternative solutions

I was able run the following steps locally in the readthedocs container to install docker

(buildtest)  ~/Documents/github/buildtest/ [container_support] docker run -u root -it --privileged readthedocs/build:ubuntu-20.04-2021.09.23 bash
root@7317ea91f9ac:/home/docs# apt-get update
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:2 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [2896 kB]
Hit:3 http://archive.ubuntu.com/ubuntu focal InRelease              
Get:4 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:6 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [29.3 kB]
Get:7 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [1117 kB]
Get:8 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [3109 kB]
Get:9 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [1421 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [3597 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [32.0 kB]
Get:12 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [3046 kB]
Get:13 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [28.6 kB]
Get:14 http://archive.ubuntu.com/ubuntu focal-backports/main amd64 Packages [55.2 kB]
Fetched 15.7 MB in 2s (9882 kB/s)                           
Reading package lists... Done
root@7317ea91f9ac:/home/docs# apt-get install -y apt-transport-https ca-certificates curl software-properties-common
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libcurl4 python3-software-properties
The following NEW packages will be installed:
  apt-transport-https
The following packages will be upgraded:
  ca-certificates curl libcurl4 python3-software-properties software-properties-common
5 upgraded, 1 newly installed, 0 to remove and 319 not upgraded.
Need to get 583 kB of archives.
After this operation, 163 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 ca-certificates all 20230311ubuntu0.20.04.1 [152 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 apt-transport-https all 2.0.9 [1704 B]
Get:3 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 curl amd64 7.68.0-1ubuntu2.20 [161 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libcurl4 amd64 7.68.0-1ubuntu2.20 [235 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 software-properties-common all 0.99.9.12 [10.4 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 python3-software-properties all 0.99.9.12 [21.7 kB]
Fetched 583 kB in 0s (2300 kB/s)                  
debconf: delaying package configuration, since apt-utils is not installed
(Reading database ... 262049 files and directories currently installed.)
Preparing to unpack .../0-ca-certificates_20230311ubuntu0.20.04.1_all.deb ...
Unpacking ca-certificates (20230311ubuntu0.20.04.1) over (20210119~20.04.1) ...
Selecting previously unselected package apt-transport-https.
Preparing to unpack .../1-apt-transport-https_2.0.9_all.deb ...
Unpacking apt-transport-https (2.0.9) ...
Preparing to unpack .../2-curl_7.68.0-1ubuntu2.20_amd64.deb ...
Unpacking curl (7.68.0-1ubuntu2.20) over (7.68.0-1ubuntu2.7) ...
Preparing to unpack .../3-libcurl4_7.68.0-1ubuntu2.20_amd64.deb ...
Unpacking libcurl4:amd64 (7.68.0-1ubuntu2.20) over (7.68.0-1ubuntu2.7) ...
Preparing to unpack .../4-software-properties-common_0.99.9.12_all.deb ...
Unpacking software-properties-common (0.99.9.12) over (0.98.9.5) ...
Preparing to unpack .../5-python3-software-properties_0.99.9.12_all.deb ...
Unpacking python3-software-properties (0.99.9.12) over (0.98.9.5) ...
Setting up apt-transport-https (2.0.9) ...
Setting up ca-certificates (20230311ubuntu0.20.04.1) ...
Updating certificates in /etc/ssl/certs...
rehash: warning: skipping ca-certificates.crt,it does not contain exactly one certificate or CRL
26 added, 18 removed; done.
Setting up python3-software-properties (0.99.9.12) ...
Setting up libcurl4:amd64 (7.68.0-1ubuntu2.20) ...
Setting up curl (7.68.0-1ubuntu2.20) ...
Setting up software-properties-common (0.99.9.12) ...
Processing triggers for libc-bin (2.31-0ubuntu9) ...
Processing triggers for dbus (1.12.16-2ubuntu2.1) ...
Processing triggers for ca-certificates (20230311ubuntu0.20.04.1) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
root@7317ea91f9ac:/home/docs# apt-get install ca-certificates curl gnupg
Reading package lists... Done
Building dependency tree       
Reading state information... Done
ca-certificates is already the newest version (20230311ubuntu0.20.04.1).
ca-certificates set to manually installed.
curl is already the newest version (7.68.0-1ubuntu2.20).
The following additional packages will be installed:
  dirmngr gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client gpg-wks-server gpgconf gpgsm gpgv
Suggested packages:
  pinentry-gnome3 tor parcimonie xloadimage scdaemon
The following packages will be upgraded:
  dirmngr gnupg gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client gpg-wks-server gpgconf gpgsm gpgv
11 upgraded, 0 newly installed, 0 to remove and 308 not upgraded.
Need to get 2563 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] install -m 0755 -d /etc/apt/keyrings^C
root@7317ea91f9ac:/home/docs# apt-get install ca-certificates curl gnupg
Reading package lists... Done
Building dependency tree       
Reading state information... Done
ca-certificates is already the newest version (20230311ubuntu0.20.04.1).
ca-certificates set to manually installed.
curl is already the newest version (7.68.0-1ubuntu2.20).
The following additional packages will be installed:
  dirmngr gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client gpg-wks-server gpgconf gpgsm gpgv
Suggested packages:
  pinentry-gnome3 tor parcimonie xloadimage scdaemon
The following packages will be upgraded:
  dirmngr gnupg gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client gpg-wks-server gpgconf gpgsm gpgv
11 upgraded, 0 newly installed, 0 to remove and 308 not upgraded.
Need to get 2563 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 gpg-wks-client amd64 2.2.19-3ubuntu2.2 [97.4 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 dirmngr amd64 2.2.19-3ubuntu2.2 [330 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 gpg-wks-server amd64 2.2.19-3ubuntu2.2 [90.2 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 gnupg-utils amd64 2.2.19-3ubuntu2.2 [481 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 gpg-agent amd64 2.2.19-3ubuntu2.2 [232 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 gpg amd64 2.2.19-3ubuntu2.2 [482 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 gpgconf amd64 2.2.19-3ubuntu2.2 [124 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 gnupg-l10n all 2.2.19-3ubuntu2.2 [51.7 kB]
Get:9 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 gnupg all 2.2.19-3ubuntu2.2 [259 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 gpgsm amd64 2.2.19-3ubuntu2.2 [217 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 gpgv amd64 2.2.19-3ubuntu2.2 [200 kB]
Fetched 2563 kB in 1s (1933 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
(Reading database ... 262058 files and directories currently installed.)
Preparing to unpack .../00-gpg-wks-client_2.2.19-3ubuntu2.2_amd64.deb ...
Unpacking gpg-wks-client (2.2.19-3ubuntu2.2) over (2.2.19-3ubuntu2.1) ...
Preparing to unpack .../01-dirmngr_2.2.19-3ubuntu2.2_amd64.deb ...
Unpacking dirmngr (2.2.19-3ubuntu2.2) over (2.2.19-3ubuntu2.1) ...
Preparing to unpack .../02-gpg-wks-server_2.2.19-3ubuntu2.2_amd64.deb ...
Unpacking gpg-wks-server (2.2.19-3ubuntu2.2) over (2.2.19-3ubuntu2.1) ...
Preparing to unpack .../03-gnupg-utils_2.2.19-3ubuntu2.2_amd64.deb ...
Unpacking gnupg-utils (2.2.19-3ubuntu2.2) over (2.2.19-3ubuntu2.1) ...
Preparing to unpack .../04-gpg-agent_2.2.19-3ubuntu2.2_amd64.deb ...
Unpacking gpg-agent (2.2.19-3ubuntu2.2) over (2.2.19-3ubuntu2.1) ...
Preparing to unpack .../05-gpg_2.2.19-3ubuntu2.2_amd64.deb ...
Unpacking gpg (2.2.19-3ubuntu2.2) over (2.2.19-3ubuntu2.1) ...
Preparing to unpack .../06-gpgconf_2.2.19-3ubuntu2.2_amd64.deb ...
Unpacking gpgconf (2.2.19-3ubuntu2.2) over (2.2.19-3ubuntu2.1) ...
Preparing to unpack .../07-gnupg-l10n_2.2.19-3ubuntu2.2_all.deb ...
Unpacking gnupg-l10n (2.2.19-3ubuntu2.2) over (2.2.19-3ubuntu2.1) ...
Preparing to unpack .../08-gnupg_2.2.19-3ubuntu2.2_all.deb ...
Unpacking gnupg (2.2.19-3ubuntu2.2) over (2.2.19-3ubuntu2.1) ...
Preparing to unpack .../09-gpgsm_2.2.19-3ubuntu2.2_amd64.deb ...
Unpacking gpgsm (2.2.19-3ubuntu2.2) over (2.2.19-3ubuntu2.1) ...
Preparing to unpack .../10-gpgv_2.2.19-3ubuntu2.2_amd64.deb ...
Unpacking gpgv (2.2.19-3ubuntu2.2) over (2.2.19-3ubuntu2.1) ...
Setting up gpgv (2.2.19-3ubuntu2.2) ...
Setting up gnupg-l10n (2.2.19-3ubuntu2.2) ...
Setting up gpgconf (2.2.19-3ubuntu2.2) ...
Setting up gpg (2.2.19-3ubuntu2.2) ...
Setting up gnupg-utils (2.2.19-3ubuntu2.2) ...
Setting up gpg-agent (2.2.19-3ubuntu2.2) ...
Setting up gpgsm (2.2.19-3ubuntu2.2) ...
Setting up dirmngr (2.2.19-3ubuntu2.2) ...
Setting up gpg-wks-server (2.2.19-3ubuntu2.2) ...
Setting up gpg-wks-client (2.2.19-3ubuntu2.2) ...
Setting up gnupg (2.2.19-3ubuntu2.2) ...
Processing triggers for install-info (6.7.0.dfsg.2-5) ...
root@7317ea91f9ac:/home/docs# install -m 0755 -d /etc/apt/keyrings
root@7317ea91f9ac:/home/docs# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
root@7317ea91f9ac:/home/docs# chmod a+r /etc/apt/keyrings/docker.gpg
root@7317ea91f9ac:/home/docs# echo \
>   "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
>   "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
>   tee /etc/apt/sources.list.d/docker.list > /dev/null
root@7317ea91f9ac:/home/docs# apt-get update
Get:1 https://download.docker.com/linux/ubuntu focal InRelease [57.7 kB]
Hit:2 http://security.ubuntu.com/ubuntu focal-security InRelease                                                                      
Get:3 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages [39.3 kB]
Hit:4 http://archive.ubuntu.com/ubuntu focal InRelease   
Hit:5 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:6 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Fetched 97.0 kB in 1s (158 kB/s)
Reading package lists... Done
root@7317ea91f9ac:/home/docs# apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  apparmor docker-ce-rootless-extras iptables libip4tc2 libip6tc2 libmnl0 libnetfilter-conntrack3 libnfnetlink0 libnftnl11 libseccomp2 libxtables12 pigz slirp4netns
Suggested packages:
  apparmor-profiles-extra apparmor-utils aufs-tools cgroupfs-mount | cgroup-lite firewalld kmod nftables
The following NEW packages will be installed:
  apparmor containerd.io docker-buildx-plugin docker-ce docker-ce-cli docker-ce-rootless-extras docker-compose-plugin iptables libip6tc2 libmnl0 libnetfilter-conntrack3 libnfnetlink0 libnftnl11 libxtables12 pigz slirp4netns
The following packages will be upgraded:
  libip4tc2 libseccomp2
2 upgraded, 16 newly installed, 0 to remove and 306 not upgraded.
Need to get 115 MB of archives.
After this operation, 414 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://download.docker.com/linux/ubuntu focal/stable amd64 containerd.io amd64 1.6.24-1 [28.6 MB]
Get:2 http://archive.ubuntu.com/ubuntu focal/universe amd64 pigz amd64 2.4-1 [57.4 kB] 
Get:3 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libseccomp2 amd64 2.5.1-1ubuntu1~20.04.2 [42.5 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libip4tc2 amd64 1.8.4-3ubuntu2.1 [19.1 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal/main amd64 libmnl0 amd64 1.0.4-2 [12.3 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libxtables12 amd64 1.8.4-3ubuntu2.1 [28.7 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 apparmor amd64 2.13.3-7ubuntu5.2 [502 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libip6tc2 amd64 1.8.4-3ubuntu2.1 [19.4 kB]
Get:9 http://archive.ubuntu.com/ubuntu focal/main amd64 libnfnetlink0 amd64 1.0.1-3build1 [13.8 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal/main amd64 libnetfilter-conntrack3 amd64 1.0.7-2 [41.4 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal/main amd64 libnftnl11 amd64 1.1.5-1 [57.8 kB]
Get:12 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 iptables amd64 1.8.4-3ubuntu2.1 [390 kB]
Get:13 https://download.docker.com/linux/ubuntu focal/stable amd64 docker-buildx-plugin amd64 0.11.2-1~ubuntu.20.04~focal [28.2 MB]
Get:14 http://archive.ubuntu.com/ubuntu focal/universe amd64 slirp4netns amd64 0.4.3-1 [74.3 kB]
Get:15 https://download.docker.com/linux/ubuntu focal/stable amd64 docker-ce-cli amd64 5:24.0.6-1~ubuntu.20.04~focal [13.3 MB]
Get:16 https://download.docker.com/linux/ubuntu focal/stable amd64 docker-ce amd64 5:24.0.6-1~ubuntu.20.04~focal [22.6 MB]
Get:17 https://download.docker.com/linux/ubuntu focal/stable amd64 docker-ce-rootless-extras amd64 5:24.0.6-1~ubuntu.20.04~focal [9038 kB]
Get:18 https://download.docker.com/linux/ubuntu focal/stable amd64 docker-compose-plugin amd64 2.21.0-1~ubuntu.20.04~focal [11.9 MB]
Fetched 115 MB in 3s (40.3 MB/s)                 
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package pigz.
(Reading database ... 262058 files and directories currently installed.)
Preparing to unpack .../archives/pigz_2.4-1_amd64.deb ...
Unpacking pigz (2.4-1) ...
Preparing to unpack .../libseccomp2_2.5.1-1ubuntu1~20.04.2_amd64.deb ...
Unpacking libseccomp2:amd64 (2.5.1-1ubuntu1~20.04.2) over (2.4.3-1ubuntu3.20.04.3) ...
Setting up libseccomp2:amd64 (2.5.1-1ubuntu1~20.04.2) ...
(Reading database ... 262067 files and directories currently installed.)
Preparing to unpack .../00-libip4tc2_1.8.4-3ubuntu2.1_amd64.deb ...
Unpacking libip4tc2:amd64 (1.8.4-3ubuntu2.1) over (1.8.4-3ubuntu2) ...
Selecting previously unselected package libmnl0:amd64.
Preparing to unpack .../01-libmnl0_1.0.4-2_amd64.deb ...
Unpacking libmnl0:amd64 (1.0.4-2) ...
Selecting previously unselected package libxtables12:amd64.
Preparing to unpack .../02-libxtables12_1.8.4-3ubuntu2.1_amd64.deb ...
Unpacking libxtables12:amd64 (1.8.4-3ubuntu2.1) ...
Selecting previously unselected package apparmor.
Preparing to unpack .../03-apparmor_2.13.3-7ubuntu5.2_amd64.deb ...
Unpacking apparmor (2.13.3-7ubuntu5.2) ...
Selecting previously unselected package libip6tc2:amd64.
Preparing to unpack .../04-libip6tc2_1.8.4-3ubuntu2.1_amd64.deb ...
Unpacking libip6tc2:amd64 (1.8.4-3ubuntu2.1) ...
Selecting previously unselected package libnfnetlink0:amd64.
Preparing to unpack .../05-libnfnetlink0_1.0.1-3build1_amd64.deb ...
Unpacking libnfnetlink0:amd64 (1.0.1-3build1) ...
Selecting previously unselected package libnetfilter-conntrack3:amd64.
Preparing to unpack .../06-libnetfilter-conntrack3_1.0.7-2_amd64.deb ...
Unpacking libnetfilter-conntrack3:amd64 (1.0.7-2) ...
Selecting previously unselected package libnftnl11:amd64.
Preparing to unpack .../07-libnftnl11_1.1.5-1_amd64.deb ...
Unpacking libnftnl11:amd64 (1.1.5-1) ...
Selecting previously unselected package iptables.
Preparing to unpack .../08-iptables_1.8.4-3ubuntu2.1_amd64.deb ...
Unpacking iptables (1.8.4-3ubuntu2.1) ...
Selecting previously unselected package containerd.io.
Preparing to unpack .../09-containerd.io_1.6.24-1_amd64.deb ...
Unpacking containerd.io (1.6.24-1) ...
Selecting previously unselected package docker-buildx-plugin.
Preparing to unpack .../10-docker-buildx-plugin_0.11.2-1~ubuntu.20.04~focal_amd64.deb ...
Unpacking docker-buildx-plugin (0.11.2-1~ubuntu.20.04~focal) ...
Selecting previously unselected package docker-ce-cli.
Preparing to unpack .../11-docker-ce-cli_5%3a24.0.6-1~ubuntu.20.04~focal_amd64.deb ...
Unpacking docker-ce-cli (5:24.0.6-1~ubuntu.20.04~focal) ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../12-docker-ce_5%3a24.0.6-1~ubuntu.20.04~focal_amd64.deb ...
Unpacking docker-ce (5:24.0.6-1~ubuntu.20.04~focal) ...
Selecting previously unselected package docker-ce-rootless-extras.
Preparing to unpack .../13-docker-ce-rootless-extras_5%3a24.0.6-1~ubuntu.20.04~focal_amd64.deb ...
Unpacking docker-ce-rootless-extras (5:24.0.6-1~ubuntu.20.04~focal) ...
Selecting previously unselected package docker-compose-plugin.
Preparing to unpack .../14-docker-compose-plugin_2.21.0-1~ubuntu.20.04~focal_amd64.deb ...
Unpacking docker-compose-plugin (2.21.0-1~ubuntu.20.04~focal) ...
Selecting previously unselected package slirp4netns.
Preparing to unpack .../15-slirp4netns_0.4.3-1_amd64.deb ...
Unpacking slirp4netns (0.4.3-1) ...
Setting up libip4tc2:amd64 (1.8.4-3ubuntu2.1) ...
Setting up slirp4netns (0.4.3-1) ...
Setting up libip6tc2:amd64 (1.8.4-3ubuntu2.1) ...
Setting up apparmor (2.13.3-7ubuntu5.2) ...
Created symlink /etc/systemd/system/sysinit.target.wants/apparmor.service → /lib/systemd/system/apparmor.service.
Setting up docker-buildx-plugin (0.11.2-1~ubuntu.20.04~focal) ...
Setting up libmnl0:amd64 (1.0.4-2) ...
Setting up containerd.io (1.6.24-1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service.
Setting up docker-compose-plugin (2.21.0-1~ubuntu.20.04~focal) ...
Setting up libxtables12:amd64 (1.8.4-3ubuntu2.1) ...
Setting up docker-ce-cli (5:24.0.6-1~ubuntu.20.04~focal) ...
Setting up pigz (2.4-1) ...
Setting up libnfnetlink0:amd64 (1.0.1-3build1) ...
Setting up docker-ce-rootless-extras (5:24.0.6-1~ubuntu.20.04~focal) ...
Setting up libnftnl11:amd64 (1.1.5-1) ...
Setting up libnetfilter-conntrack3:amd64 (1.0.7-2) ...
Setting up iptables (1.8.4-3ubuntu2.1) ...
update-alternatives: using /usr/sbin/iptables-legacy to provide /usr/sbin/iptables (iptables) in auto mode
update-alternatives: using /usr/sbin/ip6tables-legacy to provide /usr/sbin/ip6tables (ip6tables) in auto mode
update-alternatives: using /usr/sbin/arptables-nft to provide /usr/sbin/arptables (arptables) in auto mode
update-alternatives: using /usr/sbin/ebtables-nft to provide /usr/sbin/ebtables (ebtables) in auto mode
Setting up docker-ce (5:24.0.6-1~ubuntu.20.04~focal) ...
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
Processing triggers for systemd (245.4-4ubuntu3.13) ...
Processing triggers for libc-bin (2.31-0ubuntu9) ...

Finally after this i started the docker service and ran the container

root@7317ea91f9ac:/home/docs# service docker start
 * Starting Docker: docker                                                                                                                                                                                                       [ OK ] 
root@7317ea91f9ac:/home/docs# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
719385e32844: Pull complete 
Digest: sha256:88ec0acaa3ec199d3b7eaf73588f4518c25f9d34f58ce9a0df68429c5af48e8d
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

To summarize i ran the following commands in the container a few were typos, so i ommitted them out

root@7317ea91f9ac:/home/docs# history
    1  apt-get update
    2  apt-get install -y apt-transport-https ca-certificates curl software-properties-common

    4  echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu focal stable" > /etc/apt/sources.list.d/docker.list
    5  apt-get update
    6  curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg

    8  apt-get install ca-certificates curl gnupg
    9  install -m 0755 -d /etc/apt/keyrings
   10  curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
   11  chmod a+r /etc/apt/keyrings/docker.gpg
   12  echo   "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" |   tee /etc/apt/sources.list.d/docker.list > /dev/null
   13  apt-get update
   14  apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

   16  service docker start
   17  docker run hello-world
   18  history

Additional context

My question is first.

Can we have option in .readthedocs.yaml to pass arbitrary options as part of the container invocation. Second, i am not sure if its possible to run some script as root. I had to use docker run -u root to get into root user. The default user is docs.

I need to run some commands as root user and i can confirm the docs user can't run commands with sudo priviledges

$ whoami
docs
$ sudo apt-get update
-sh: 1: sudo: not found
$ apt-get update
Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/

In .readthedocs.yaml there is build.commands but i think this may not run in context of root user i need some clarification on this.

My end goal would be to be able to use something like sphinx program-output to run docker commands in the documentation so commands can work. At the moment i dont know if this is possible without troubleshooting the docs build and then inspecting the logs. I know i can do this locally on my end using the readthedocs container but i dont know the internals. I was wondering if someone could help me set this up or provide some insight into how we can go about adding some features to extend readthedocs support for further customization.

@shahzebsiddiqui shahzebsiddiqui changed the title modify container startup in readthedocs RFE: readthedocs container startup customization Oct 11, 2023
@stsewd
Copy link
Member

stsewd commented Oct 11, 2023

Can we have option in .readthedocs.yaml to pass arbitrary options as part of the container invocation. Second, i am not sure if its possible to run some script as root. I had to use docker run -u root to get into root user. The default user is docs.

For security reasons, we won't allow users to change the options when a container is started. Allowing to pass --privileged would be a no.

We are considering allowing users to run commands as root, and there is also an open issue about allowing to install apt-packages while using build.commands #9599

@shahzebsiddiqui
Copy link
Author

@stsewd I understand your concern I guess it's not possible to have docker setup inside readthedocs container image. I did come across the post that --privileged is required to get docker setup in a container.

Note I tried this manually without --privileged and I got the socket error that you typically get with docker service unable to connect

@humitos
Copy link
Member

humitos commented Nov 7, 2023

I'm closing this issue since there isn't too much we can do here. Feel free to re-open if you consider.

@humitos humitos closed this as completed Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants