Setting Up a Docker Environment in a server (OVH): Step-by-Step Tutorial
1. Generate SSH Key
ssh-keygen -b 4096
This creates a 4096-bit SSH key pair for secure authentication.
2. Connect to Your Instance
ssh -i ~/.ssh/keyname root@XxX.XxX.XxX.XxX
Replace keyname
with your SSH key filename and XxX.XxX.XxX.XxX
with your instance’s IP address.
3. Install Docker on Ubuntu
First, update the system and install prerequisites:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
Add Docker’s GPG key:
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
Configure the Docker repository:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Update package list and install Docker:
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
4. Verify Docker Installation
sudo docker run hello-world
This command downloads a test image and runs it to verify the installation.
5. Clone Your Repository
git clone https://JesusGF1:personalaccesstokenp@github.com/JesusGF1/reponame.git
Replace personalaccesstokenp
with your actual GitHub personal access token and reponame
with your repository name.
6. Build and Run Docker Container
Build the Docker image:
docker build -t reponame .
Run the container interactively:
docker run -it -p 8000:8000 reponame /bin/bash
7. Set Up Development Environment
Install required tools and dependencies:
cd /usr/bin
wget whatever you need
pip install package1==4.1 package2==1.83
pip install -e /folder
8. Run the Django Server
python /manage.py runserver 0.0.0.0:8000 --settings=web.settings.development
Your application should now be running and accessible on port 8000.