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

Error on docker-ce install, installed docker-ce package post-installation script subprocess returned error exit status 1 #121

Closed
mdaffad opened this issue Jul 11, 2023 · 2 comments

Comments

@mdaffad
Copy link

mdaffad commented Jul 11, 2023

I tried to install docker-ce on ubuntu cloud image. I followed steps on readme file provided by ubuntu template and using ubuntu-cloudimg.pkr.hcl.

I found this error:

    cloudimg.image.qemu.cloudimg: Job for docker.service failed because the control process exited with error code.
    cloudimg.image.qemu.cloudimg: See "systemctl status docker.service" and "journalctl -xe" for details.
    cloudimg.image.qemu.cloudimg: invoke-rc.d: initscript docker, action "start" failed.
    cloudimg.image.qemu.cloudimg: ● docker.service - Docker Application Container Engine
    cloudimg.image.qemu.cloudimg:      Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
    cloudimg.image.qemu.cloudimg:      Active: activating (auto-restart) (Result: exit-code) since Tue 2023-07-11 04:20:07 UTC; 7ms ago
    cloudimg.image.qemu.cloudimg: TriggeredBy: ● docker.socket
    cloudimg.image.qemu.cloudimg:        Docs: https://docs.docker.com
    cloudimg.image.qemu.cloudimg:     Process: 3555 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
    cloudimg.image.qemu.cloudimg:    Main PID: 3555 (code=exited, status=1/FAILURE)
    cloudimg.image.qemu.cloudimg: dpkg: error processing package docker-ce (--configure):
    cloudimg.image.qemu.cloudimg:  installed docker-ce package post-installation script subprocess returned error exit status 1
    cloudimg.image.qemu.cloudimg: Processing triggers for man-db (2.9.1-1) ...
    cloudimg.image.qemu.cloudimg: Processing triggers for systemd (245.4-4ubuntu3.22) ...
    cloudimg.image.qemu.cloudimg: Errors were encountered while processing:
    cloudimg.image.qemu.cloudimg:  docker-ce

Here are my system information

Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.2 LTS
Release:	22.04
Codename:	jammy

After some try and error using solution provided on:

  1. Docker Engine does not start on Ubuntu 22.04 due to iptables issues  docker/for-linux#1437
  2. https://forums.docker.com/t/ubuntu-22-04-and-5-23-0-0-1-now-fails-to-start-please-suggest-debug/134472
  3. Deinstall and install of docker ce fails on ubuntu 18.04 moby/moby#41792

I fixed it with this steps:

  1. I make custom script in custom-script.sh. It is using separated install steps like on this discussion, and install using iptables legacy like on this
sudo rm -rf /var/lib/docker /etc/docker
sudo rm /etc/apparmor.d/docker
sudo groupdel docker
sudo rm -rf /var/run/docker.sock
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common lsb-release
lsb_release -a
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add
sudo add-apt-repository 'deb [arch=amd64] https://download.docker.com/linux/ubuntu jammy stable'
update-alternatives --set iptables /usr/sbin/iptables-legacy
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
sudo apt-get update
sudo apt-cache show docker-ce
sudo apt-get install -y containerd.io
sudo apt-get install -y docker-ce-cli
sudo apt-get install -y docker-ce
echo $USER
sudo usermod -aG docker $USER
  1. I update the setup-boot.sh to not delete the kernel, instead i delete the kernel after the docker process installation done using new script i created in clear-kernel.sh.
# setup-boot.sh
packer_apt_proxy_config="/etc/apt/apt.conf.d/packer-proxy.conf"
if  [ ! -z  "${http_proxy}" ]; then
  echo "Acquire::http::Proxy \"${http_proxy}\";" >> ${packer_apt_proxy_config}
fi
if  [ ! -z  "${https_proxy}" ]; then
  echo "Acquire::https::Proxy \"${https_proxy}\";" >> ${packer_apt_proxy_config}
fi

cloud-init clean --logs
# The cloud image for qemu has a kernel already. Remove it, since the user
# should either install a kernel in the customize script, or let MAAS install
# the right kernel when deploying.
apt-get remove --purge -y linux-virtual 'linux-image-*'
apt-get autoremove --purge -yq
apt-get clean -yq
  1. I update theubuntu-cloudimg.pkr.hcl to run above scripts in order.
# truncated
build {
  name    = "cloudimg.image"
  sources = ["source.qemu.cloudimg"]

  provisioner "shell" {
    environment_vars = concat(local.proxy_env, ["DEBIAN_FRONTEND=noninteractive"])
    scripts          = ["${path.root}/scripts/cloudimg/setup-boot.sh"]
  }


  provisioner "shell" {
    environment_vars  = local.proxy_env
    expect_disconnect = true
    scripts           = ["${var.customize_script}"]
  }

  provisioner "shell" {
    environment_vars = concat(local.proxy_env, ["DEBIAN_FRONTEND=noninteractive"])
    scripts          = ["${path.root}/scripts/cloudimg/clean-kernel.sh"]
  }

# rest of file template

I am new on this tools, Packer and MAAS. I just want to know if this is a right step or if have any drawback.

Thanks.

@alexsander-souza
Copy link
Contributor

I can't say whether this is the best fix for the Docker issue, but from the Packer/MAAS standpoint the way you implemented it is perfectly fine.

@mdaffad
Copy link
Author

mdaffad commented Jul 24, 2023

After checking again several times, it doesn't need legacy iptable and separated install step. I think it only needs kernel during installation. Here is the updated script, hope it helps:

sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add
sudo add-apt-repository 'deb [arch=amd64] https://download.docker.com/linux/ubuntu jammy stable'
sudo apt-get update
sudo apt-cache show docker-ce
sudo apt-get install -y containerd.io docker-ce-cli docker-ce
echo $USER
sudo usermod -aG docker $USER

After some try and error using solution provided on:

  1. Docker Engine does not start on Ubuntu 22.04 due to iptables issues  docker/for-linux#1437
  2. https://forums.docker.com/t/ubuntu-22-04-and-5-23-0-0-1-now-fails-to-start-please-suggest-debug/134472
  3. Deinstall and install of docker ce fails on ubuntu 18.04 moby/moby#41792

I fixed it with this steps:

  1. I make custom script in custom-script.sh. It is using separated install steps like on this discussion, and install using iptables legacy like on this
sudo rm -rf /var/lib/docker /etc/docker
sudo rm /etc/apparmor.d/docker
sudo groupdel docker
sudo rm -rf /var/run/docker.sock
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common lsb-release
lsb_release -a
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add
sudo add-apt-repository 'deb [arch=amd64] https://download.docker.com/linux/ubuntu jammy stable'
update-alternatives --set iptables /usr/sbin/iptables-legacy
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
sudo apt-get update
sudo apt-cache show docker-ce
sudo apt-get install -y containerd.io
sudo apt-get install -y docker-ce-cli
sudo apt-get install -y docker-ce
echo $USER
sudo usermod -aG docker $USER

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

2 participants