01. Initializing the Docker Environment
Installing Docker CE
Installing Required Packages: If you are using Essential packages for Docker CE in CentOS, such as utils
, device-mapper-persistent-data
, and lvm2
, are installed using the yum
package manager.
I'm using the Linux EC2 2023 server.
To install Docker on Amazon Linux 2 or Amazon Linux 2023
1.Update the installed packages and package cache on your instance.
$ sudo yum update -y
2.Install the most recent Docker Community Edition package.
For Amazon Linux 2, run the following:
$ sudo amazon-linux-extras install docker
For Amazon Linux 2023, run the following:
$ sudo yum install -y docker
3.Start and enable the Docker service
$ systemctl enable --now docker.service
$ systemctl ststus docker.service
Add the ec2-user to the docker group so that you can run Docker commands without using sudo.
$ sudo usermod -a -G docker ec2-user
Pick up the new docker group permissions by logging out and logging back in again. To do this, close your current SSH terminal window and reconnect to your instance in a new one. Your new SSH session should have the appropriate docker group permissions.
Verify that the ec2-user can run Docker commands without using sudo.
$ docker ps -a
Top comments (0)