Where IT meets innovation, IT-INFO lights the path to technological brilliance
This guide will walk you through the installation of Docker and Docker Compose, and how to run your first containerized application.
First, let's install Docker. The following commands will work for a variety of Linux distributions. If you're using Windows or macOS, please refer to the official Docker documentation.
sudo apt-get update sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg \ lsb-release curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io sudo systemctl start docker sudo systemctl enable docker
Next, install Docker Compose by running the following commands:
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose docker-compose --version
With Docker installed, you can now run your first container. We'll use the hello-world
image to verify that everything is working correctly.
sudo docker run hello-world
Docker Compose is a tool for defining and running multi-container Docker applications. Let's create a simple web application using Docker Compose.
Create a directory for your project and navigate into it:
mkdir my-web-app cd my-web-app
In this directory, create a file named docker-compose.yml
with the following content:
version: '3' services: web: image: nginx ports: - "80:80"
Now, run the application using Docker Compose:
sudo docker-compose up
Your web application is now running and accessible at http://localhost.
In this guide, you've learned how to install Docker and Docker Compose, and how to run your first containerized application. Docker and Docker Compose are powerful tools that simplify the process of deploying and managing applications in containers.
Created on Aug. 7, 2024, 12:04 p.m.