Debug School

rakesh kumar
rakesh kumar

Posted on

Deploying a website using containerization on Windows Subsystem for Linux (WSL)

How to install wsl
how to open wsl in visual studio
how to Install Docker Desktop on Windows
how to Install Docker Desktop on linux
how to create docker file and create image

How to install wsl

Step1:Enable Required Windows Features
You must have these Windows features enabled:

Virtual Machine Platform

Windows Subsystem for Linux

Windows Hypervisor Platform (sometimes needed)

How to enable:

Open Control Panel → Programs → Turn Windows features on or off.
Enter fullscreen mode Exit fullscreen mode

Check the boxes for:

Windows Subsystem for Linux

Virtual Machine Platform

Windows Hypervisor Platform (if available)

Click OK and restart your PC

Image description

step2: open cmd not gitbash

wsl --install
Enter fullscreen mode Exit fullscreen mode

step3:type password
step4: you will get prompt

rakes@Zebronics:/mnt/c/Users/rakes$
Enter fullscreen mode Exit fullscreen mode

step5: press window +R

how to open wsl in visual studio

step 1:open visual studio
step2: Open VS Code.

Go to the Extensions view (Ctrl+Shift+X).

Search for "WSL" or "Remote - WSL".

If it is not installed, click Install.

If it is already installed, ensure it is enabled

step3:Go to the Extensions view (Ctrl+Shift+p)
Press F1 or Ctrl+Shift+P to open the Command Palette.

Type and select WSL: Connect to WSL (or WSL: Connect to WSL using Distro for a specific Linux distribution).

Use the File menu to open a folder located in your WSL filesystem.

how to Install Docker Desktop on Windows

step 1:go to site

https://docs.docker.com/desktop/setup/install/windows-install/
Enter fullscreen mode Exit fullscreen mode

Image description

step 2:Enable WSL Integration

Enable WSL Integration

Open Docker Desktop.

Go to Settings > Resources > WSL Integration.

Enable integration for your Ubuntu distribution.

Restart Docker Desktop and your WSL terminal.

Try your command again in WSL:

text
docker --version

Image description

step 3:Create a New File Named Dockerfile
In the Explorer sidebar, right-click on your project folder.

Select New File.

Name the file exactly:

Dockerfile
(No extension, capital "D", case-sensitive on Linux/WSL.)

  1. Add Your Dockerfile Content Click to open the new Dockerfile.

Paste your Dockerfile instructions, for example:

FROM ubuntu:20.04

RUN apt-get update && apt-get install -y wget net-tools

RUN wget https://sourceforge.net/projects/xampp/files/XAMPP%20Linux/8.2.12/xampp-linux-x64-8.2.12-0-installer.run
RUN chmod +x xampp-linux-x64-8.2.12-0-installer.run
RUN yes | ./xampp-linux-x64-8.2.12-0-installer.run

EXPOSE 80 3306

CMD ["/opt/lampp/lampp", "start"]

EXPOSE 80 3306

CMD ["/opt/lampp/lampp", "start"]
Enter fullscreen mode Exit fullscreen mode

then save as from filemenu

Image description

how to rename dockerfile

mv my-xampp-image.dockerfile Dockerfile
Enter fullscreen mode Exit fullscreen mode

how to Install Docker Desktop on linux

how-to-install-and-use-docker-on-ubuntu
how-to-install-docker-in-linux

how to create docker file and create image

step1
Visit the Official XAMPP Download Page
Go to the XAMPP official download page.

Scroll to the section labeled XAMPP for Linux
step2 right click installer and copy link

Image description

copied link is

https://sourceforge.net/projects/xampp/files/XAMPP%20Linux/8.2.12/xampp-linux-x64-8.2.12-0-installer.run
Enter fullscreen mode Exit fullscreen mode
RUN wget https://sourceforge.net/projects/xampp/files/XAMPP%20Linux/8.2.12/xampp-linux-x64-8.2.12-0-installer.run
Enter fullscreen mode Exit fullscreen mode

step3 create dockerfile

FROM ubuntu:20.04

RUN apt-get update && apt-get install -y wget net-tools

RUN wget https://sourceforge.net/projects/xampp/files/XAMPP%20Linux/8.2.12/xampp-linux-x64-8.2.12-0-installer.run
RUN chmod +x xampp-linux-x64-8.2.12-0-installer.run
RUN yes | ./xampp-linux-x64-8.2.12-0-installer.run

EXPOSE 80 3306

CMD ["/opt/lampp/lampp", "start"]
Enter fullscreen mode Exit fullscreen mode

step 4 save as from menu

Image description

step5: run docker command to build image

docker build -t my-xampp-image .
Enter fullscreen mode Exit fullscreen mode

step6: check docker image created

docker images
Enter fullscreen mode Exit fullscreen mode

Top comments (0)