简体   繁体   中英

Run Docker as rootless mode

I am trying to run a docker as a rootless mode in ubuntu VM.

  1. I am provisioning the VM using the terraform script.
  2. I am using the terraform run module to execute commands and prerequisites.
  3. but when I have added docker as rootless mode commands in this run module those scripts are not executing even though I switch the new user. Below are the commands I need to execute as another user in the terraform run module.
sudo apt-get install -y uidmap
curl -fsSL https://get.docker.com/rootless | sh
export DOCKER_HOST=unix:///run/user/1000/docker.sock
systemctl --user status docker
  1. I am getting an error as Refusing to install rootless Docker as the root user
  2. My goal is to automate this using a terraform run module.

should any could help to solve this issue or is there any other workaround for this.

Thanks in Advance.

I have tried with switch user and execute but still, these commands are not executing.

sudo apt-get install -y uidmap
curl -fsSL https://get.docker.com/rootless | sh
export DOCKER_HOST=unix:///run/user/1000/docker.sock
systemctl --user status docker

I would like to automate this using a terraform run module or any other way but the only thing is this should be executed once VM is provision.

Read the script https://get.docker.com/rootless where it says "This script should be run with an unprivileged user and install/setup Docker under $HOME/bin/"

If you do still want to install it then you just need to learn how to read shell scripts as there is this part in the script:

# User verification: deny running as root (unless forced?)
if [ "$(id -u)" = "0" ] && [ -z "$FORCE_ROOTLESS_INSTALL" ]; then
    >&2 echo "Refusing to install rootless Docker as the root user"; exit 1
fi

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM