2

I have installed docker from binaries in my Linux EC2 machine.Now everytime the server reboots i need to run below commands

 sudo docker &
 sudo chmod 666 /var/run/docker.sock

Otherwise it give me below error

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?                                                                                  

So i have give the above mentioned commands in ec2-user data.But still its not working and i still need to run above commands manually.

Note below is not working for me,may be because i have installed from binaries and not using yum

 sudo groupadd docker
 sudo usermod -aG docker ${USER}
 su -s ${USER}
  • Welcome AWS_Beginner. You mention that something doesn't work, but didn't provide the exact error, which makes it really hard to help you. Also you mention yum but do not specify which OS and version you're running (yum is available on many distros, where each may need different solutions). Another good information would be how the service is being started at boot time. Is it systemd? systemv? manually? Which user owns /var/run/docker.sock and which permissions are set on it before you run your command? The steps you followed to install docker would also help. – Zip May 21 at 18:42
  • @Zip Thanks.I have given exact error above.OS is RHEl 7.5. – AWS_Beginner May 22 at 6:13
  • Is this what you are looking for? stackoverflow.com/q/37227349/8438982 – Raj Srujan Jalem May 24 at 8:41
0

Did you follow the instructions to Configure Docker to start on boot?

Anyway I suggest you start over, create a fresh new EC2 instance and install docker with yum. It will do all the right things for you. Here are the instructions for CentOS, for Ubuntu or for Debian.

Alternatively spin up the EC2 instance from ECS-optimised AMI that already comes with docker installed.

Hope that helps :)

| improve this answer | |
  • I cannot spin another instance due to limitations at my shop.OS is RHEL 7.5 and they have disabled yum.So i cannot install anything using yum. – AWS_Beginner May 22 at 5:54
  • ec2-user@ip-172-31-15-141 ~]$ sudo systemctl enable docker Failed to enable unit: Unit file docker.service does not exist. [ec2-user@ip-172-31-15-141 ~]$ ps -ef | grep docker root 1339 1310 0 06:08 pts/0 00:00:00 sudo dockerd root 1341 1339 0 06:08 pts/0 00:00:00 dockerd root 1347 1341 0 06:08 ? 00:00:00 docker-containerd --config /var/run/docker/containerd/containerd.toml ec2-user 1598 1570 0 06:18 pts/1 00:00:00 grep --color=auto docker [ec2-user@ip-172-31-15-141 ~]$` – AWS_Beginner May 22 at 6:19
  • @AWS_Beginner if your employer doesn’t give you the tools to do your job (ie yum) then it’s a hard call. – MLu May 22 at 6:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.