Windows WSL 安装docker

1. Add the necessary repository

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

2. Install the necessary dependencies

sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y

3. Install Docker

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli docker-compose containerd.io -y
sudo apt install gnome-keyring

4. Add your user to the Docker group

sudo usermod -aG docker $USER
sudo chmod 666 /var/run/docker.sock
sudo service docker restart

5. Testing the installation

docker version
docker pull hello-world

6.fix "System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down"

sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig

sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target

exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME

snap version

参考文档

https://www.zdnet.com/article/docker-101-how-to-install-docker-on-ubuntu-server-22-04/
https://gist.github.com/alyleite/ca8b10581dbecd722d9dcc35b50d9b2b
https://docs.docker.com/engine/install/ubuntu/

相关阅读

添加新评论