O WSL da atualização do Windows 10 Spring (2018) permite que eu execute o docker nele? e porque?

4

Ouvi dizer que "Atualização do Windows 10 Spring traz suporte ao WSL Unix Sockets ".

Antes, não consegui executar o serviço de encaixe em um WSL devido a um erro de soquete.

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

O novo recurso de atualização de primavera do WLS é suficiente para executar o docker no WSL?

    
por Daniel Santos 27.08.2018 / 21:19

1 resposta

6

Does the new WLS spring update feature is enough to run Docker on WSL?

A Microsoft não suporta a execução do daemon do Docker (também conhecido como serviço) na instância do WSL.

We frequently get asked about running docker from within the Windows Subsystem for Linux (WSL). We don’t support running the docker daemon directly in WSL. But what you can do is call into the daemon running under Windows from WSL. What does this let you do? You can create docker files, build them, and run them in the daemon—Windows or Linux, depending on which runtime you have selected—all from the comfort of WSL.

[Cross Post] Interoperabilidade do WSL com o Docker

The Docker daemon can't run under WSL as it doesn't implement the necessary kernel ABI's. If you're running Docker for Windows, you are probably connecting to the Hyper-V virtual machine that it manages.

O Docker está sendo executado no WSL ou conectado de volta a Windows?

Embora o daemon não possa ser executado em uma instância do WSL, você pode usar a CLI do Docker para se conectar a um serviço do Docker em execução na instalação do Windows.

In the general settings, you’ll want to expose the daemon without TLS. This step is necessary so that the daemon listens on a TCP endpoint. If you don’t do this then you won’t be able to connect from WSL.

enter image description here

Ainda precisamos instalar o Docker dentro da WSL, pois isso nos dará acesso à CLI do Docker. Nós apenas não nos incomodamos em iniciar o servidor.

The following instructions are for Ubuntu but with the 2017 fall update+ of Windows, WSL now supports a variety of distributions so if you happen to use something other than Ubuntu then follow the Docker installation guide for your distro from Docker’s installation docs.

This will install the edge channel, change ‘edge’ to ‘stable’ if you want. You may also want to update the Docker Compose version based on the latest release.

# Environment variables you need to set so you don't have to edit the script below.
export DOCKER_CHANNEL=edge
export DOCKER_COMPOSE_VERSION=1.21.0

# Update the apt package index.
sudo apt-get update

# Install packages to allow apt to use a repository over HTTPS.
sudo apt-get install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

# Add Docker's official GPG key.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

# Verify the fingerprint.
sudo apt-key fingerprint 0EBFCD88

# Pick the release channel.
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   ${DOCKER_CHANNEL}"

# Update the apt package index.
sudo apt-get update

# Install the latest version of Docker CE.
sudo apt-get install -y docker-ce

# Allow your user to access the Docker CLI without needing root.
sudo usermod -aG docker $USER

# Install Docker Compose.
sudo curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-'uname -s'-'uname -m' -o /usr/local/bin/docker-compose &&
sudo chmod +x /usr/local/bin/docker-compose

First up, open a WSL terminal because we need to run a few commands.

Create and modify the new WSL configuration file:

sudo nano /etc/wsl.conf

# Now make it look like this and save the file when you're done:
[automount]
root = /
options = "metadata"

If you get an error the next time you start your WSL terminal don’t freak out. It’s a bug with 18.03 and you can easily fix it. Hit CTRL+Shift+ECS to open task manager, goto the “Services” tab, find the “LxssManager” service and restart it.

Configurando o Docker para Windows e WSL para funcionar sem falhas

    
por 27.08.2018 / 22:07