How to install wsl
how to open wsl in visual studio
How to Copy your website files from Windows to your WSL home directory
how to Install Docker Desktop on Windows
how to Install Docker Desktop on linux
how to create docker file and create image
Error command 'docker' could not be found in this WSL 2 distro
How to create docker image to deploy website
how to run container from docker image
how to list container
Difference Between docker ps and docker ps -a
how to exit from container
how to enter in particular container or opens a shell inside the container
How to create and starts container with volume mounts
how to Copy the File Out of the Existing Container
How to create and starts container using network bridge
how to stop all running container
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.
Check the boxes for
:
Windows Subsystem for Linux
Virtual Machine Platform
Windows Hypervisor Platform (if available)
Click OK and restart your PC
step2: open cmd not gitbash
wsl --install
step3:type password
step4: you will get prompt
rakes@Zebronics:/mnt/c/Users/rakes$
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/
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
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.)
-
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"]
then save as from filemenu
how to rename dockerfile
mv my-xampp-image.dockerfile Dockerfile
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
copied link is
https://sourceforge.net/projects/xampp/files/XAMPP%20Linux/8.2.12/xampp-linux-x64-8.2.12-0-installer.run
RUN wget https://sourceforge.net/projects/xampp/files/XAMPP%20Linux/8.2.12/xampp-linux-x64-8.2.12-0-installer.run
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"]
step 4 save as from menu
step5: run docker command to build image
docker build -t my-xampp-image .
step6: check docker image created
docker images
docker image inspect motoshare
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
# Add this line to copy your website into the container
COPY motoshare-web /opt/lampp/htdocs
# (Optional) Set permissions if needed
RUN chown -R root:root /opt/lampp/htdocs
EXPOSE 80 3306
CMD ["/opt/lampp/lampp", "start"]
How to Copy your website files from Windows to your WSL home directory
cp -r /mnt/c/xampp/htdocs/motoshare-web ~/motoshare-web
mv /home/rakes/motoshare-web /home/rakes/my-xampp-docker/
Error command 'docker' could not be found in this WSL 2 distro
How to create docker image to deploy website
step1:create docker file
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
# Add this line to copy your website into the container
COPY motoshare-web /opt/lampp/htdocs
# (Optional) Set permissions if needed
RUN chown -R root:root /opt/lampp/htdocs
EXPOSE 80 3306
CMD ["/opt/lampp/lampp", "start"]
save the file
step2:run command to create image from dockerfile
docker build -t motoshare .
docker images
docker image inspect motoshare
how to run container from docker image
docker run -it --name mycontainer motoshare bash
output
in dockerimage my path is
COPY motoshare-web /opt/lampp/htdocs
so inside htdocs itself motoshare all folder structure appear
=============ANOTHER EXAMPLE===================
docker run \
--name traccar \
--hostname traccar \
--detach --restart unless-stopped \
--publish 80:8082 \
--publish 5000-5300:5000-5300 \
--publish 5000-5300:5000-5300/udp \
traccar/traccar:latest
note
if http port is for 80 reserved then run below command
docker run \
--name traccar \
--hostname traccar \
--detach --restart unless-stopped \
--publish 8082:8082 \
--publish 5000-5300:5000-5300 \
--publish 5000-5300:5000-5300/udp \
traccar/traccar:latest
docke ps-a
<public ip-address>:8082
13.203.171.107:8082
note never run together two command run container and
wget https://github.com/traccar/traccar/releases/download/v6.8.1/traccar-linux-64-6.8.1.zip
it would crash
note
not run unzip command at root it would crash
sudo mv traccar-linux-64-*.zip /opt/
cd /opt
sudo unzip traccar-linux-64-*.zip
how to list container
docker ps -a
docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Status}}"
Note
docker ps command by default only shows running containers
not show container name
Difference Between docker ps and docker ps -a
how to exit from container
how to enter in particular container or opens a shell inside the container
docker exec -it container_name_or_id bash
docker exec -it d06f16e55c55 bash
How to create and starts container with volume mounts
docker run -it --name motocontainer -v shared-data:/data motoshare
Before running command my folder structure
After running command my folder structure
how to Copy the File Out of the Existing Container
existing file structure
docker cp 70f935f448d0:/opt/lampp/htdocs/hello.txt ./hello.txt
how to stop all running container
docker stop $(docker ps -q)
docker start $(docker ps -aq)
docker rm -f $(docker ps -aq)
docker rm $(docker ps -a -q --filter status=exited)
How to create and starts container with volume mounts
docker network create --driver bridge my-bridge-network
docker run -dit --name container1 --network my-bridge-network alpine sh
docker run -dit --name container2 --network my-bridge-network alpine sh
Step 1: Create a User-Defined Bridge Network
docker network create --driver bridge my-bridge-network
This creates a new bridge network named my-bridge-network.
Step 2: List All Networks
bash
docker network ls
Shows all Docker networks, including your new user-defined bridge.
Step 3: Inspect the Network
docker network inspect my-bridge-network
Displays details like subnet, gateway, and connected containers.
Enabling Container-to-Container Communication
When containers are attached to the same user-defined bridge network, they can communicate directly using container names.
Step 1: Run Containers on the Same Network
docker run -dit --name container1 --network my-bridge-network alpine sh
docker run -dit --name container2 --network my-bridge-network alpine sh
Both containers are now connected to my-bridge-network.
Step 2: Test Communication
Open a shell in container1:
docker exec -it container1 sh
From inside container1, ping container2 by name:
ping container2
Note:If the target container is stopped or not running, attempts to communicate with it (by name or IP) will fail. source container and target container bith should be up
so follow these step
docker start container4 container5
docker exec -it container4 sh
ping container5
Top comments (0)