Installing docker and launching container in Linux terminal (AWS).
In today's rapidly evolving technological landscape, containerization has become a cornerstone of modern software development and deployment. Docker, a leading containerization platform, offers developers a seamless and efficient way to package, distribute, and run applications. In this guide, we'll walk through the steps to install Docker and launch containers on an AWS Linux instance, empowering you to harness the power of containerization in the cloud.
Step 1: Set Up Your AWS Linux Instance Before diving into Docker installation, ensure you have an AWS EC2 instance running with a Linux operating system. You can launch a new instance through the AWS Management Console, selecting your preferred Linux distribution.
Step 2: Connect to Your AWS Instance Once your instance is up and running, connect to it using SSH. Retrieve the public DNS or IP address of your instance from the AWS Console and use it to establish a secure SSH connection
ssh -i your_key.pem ec2-user@your_instance_public_dns
Replace your_key.pem with the path to your private key file and your_instance_public_dns with the public DNS of your AWS instance.
Step 3: Install Docker With SSH access to your AWS instance, you're ready to install Docker. Execute the following commands in your terminal:
sudo yum update -y sudo yum install docker -y
This will update the package repository and install Docker on your AWS Linux instance.
Step 4: Start and Enable Docker Once Docker is installed, start the Docker service and enable it to automatically start on boot:
领英推荐
sudo service docker start sudo chkconfig docker on
Step 5: Verify Docker Installation To ensure Docker is installed correctly, run the following command:
sudo docker --version
You should see the Docker version displayed in the output, confirming a successful installation.
Step 6: Launch Your First Docker Container Now that Docker is installed, let's launch your first container. You can start with a simple container running the official Nginx image:
sudo docker run -d -p 80:80 nginx
This command pulls the Nginx image from Docker Hub, launches a container in detached mode (-d), and maps port 80 of the container to port 80 on your AWS instance (-p 80:80).
Step 7: Access Your Containerized Application Once the container is running, you can access the Nginx web server by navigating to your AWS instance's public DNS or IP address in your web browser. You should see the default Nginx welcome page, indicating that the containerized app