Skip to content

Install Docker on Ubuntu 20.04 LTS and Dotnet Spark on DockerΒΆ

Tip

Make sure to have Ubuntu 20.04 installed and turn on Ubuntu-20.04 in Docker Settings -> Resources -> WSL Integration

Use the apt command to install the docker.io package:

Bash
sudo apt-get update
sudo apt install docker.io
Start docker and enable it to start after the system reboot:
Bash
sudo systemctl enable --now docker
Run, if error "System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down"
Bash
sudo dockerd

If error "Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/json: dial unix /var/run/docker.sock: connect: permission denied"

Bash
sudo groupadd docker
sudo usermod -aG docker ${user} // where ${user} is current user "ps" 
su -s ${USER} // Log out and log back in

Restart WSL 2 ubuntu from Powershell, if su -s command doesn't work

PowerShell
Get-Service LxssManager | Restart-Service

Optionally give any user administrative privileges to docker:

Bash
sudo usermod -aG docker SOMEUSERNAME
where SOMEUSERNAME is admin user

Check docker version:

Bash
docker --version

Test Docker

Bash
docker run hello-world

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/

Install Dotnet 3.1 on Ubuntu 20.04 LTS

Bash
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-3.1
Just in case if need to clean prior installations
Bash
sudo dpkg --purge packages-microsoft-prod && sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update

Install VS Code from other post And finally, Clone sample application from HelloUdf we should be able to run and debug dotnet spark on docker

Bash
docker run -d --name dotnet-spark-helloudf --network host -v "$HOME/Projects/HelloUdf/bin/Debug:/dotnet/Debug" 3rdman/dotnet-spark:latest

Running Dotnet Spark on Docker

Install Docker composeΒΆ

Bash
sudo apt install docker-compose

Run using docker-composeΒΆ

docker-compose.yml
version: '3'
services:
    dotnet-spark-helloudf:
      container_name: dotnet-spark-helloudf
      image: 3rdman/dotnet-spark:latest
      network_mode: host
      volumes:
      - $HOME/Projects/HelloUdf/bin/Debug:/dotnet/Debug