Installing Docker and Docker Compose on an Ubuntu server:
Installing Docker and Docker Compose on an Ubuntu server:
Installing Docker on Ubuntu:
Update Package Index:
Install Dependencies: Install the packages necessary to allow apt to use a repository over HTTPS:
Add Docker's Official GPG Key: Add Docker’s official GPG key to your system:
Set Up the Stable Repository: Add the Docker repository to APT sources:
Update the Package Database: Update the package database with Docker packages from the newly added repo:
Install Docker CE: Install Docker Community Edition (CE):
Verify Docker Installation: Check that Docker is installed correctly by running the
hello-world
image:
Installing Docker Compose:
Download Docker Compose Binary:
Check the latest release of Docker Compose from the official GitHub repository.
Replace
VERSION
with the latest release version:
Apply Executable Permissions:
Create Symbolic Link:
Verify Docker Compose Installation:
Post-Installation Steps:
Manage Docker as a Non-root User (Optional):
If you want to run Docker commands without
sudo
, add your user to thedocker
group:
Log out and log back in to apply the group membership changes.
Restart Docker Service:
Test Docker Compose:
Create a
docker-compose.yml
file in your project directory.Define services and configurations in the
docker-compose.yml
.Run
docker-compose up
to start the services defined in the YAML file.
Automation Script:
Save the script to a file, for example, install_docker.sh
, then make it executable:
To execute the script, run:
Conclusion:
You have now successfully installed Docker and Docker Compose on your Ubuntu server. This setup enables you to manage and deploy containerized applications efficiently.
Last updated