In the aws-browser-ssh window, the "sudo docker ps" is working but "docker ps" is giving error.

0

I want to connect the docker-desktop to the docker aws-lightsail. it is giving error

""" error during connect: Get "http://docker.example.com/v1.48/containers/json": command [ssh -o ConnectTimeout=30 -T -l ubuntu -- ... docker system dial-stdio] has exited with exit status 255, make sure the URL is va lid, and Docker 18.09 or later is installed on the remote host: stderr=ubuntu@...: Permission denied ( publickey). """

I have tried all the steps like creating a group and other suggestion provided by chatgpt, yet the issue could not be resolved. I have also tried to uninstall and reinstall the docker. Yet the problem persists.

asked 23 days ago43 views
2 Answers
0

It appears you're encountering multiple issues related to Docker and SSH access on your AWS Lightsail instance. Let's address these one by one:

  1. "sudo docker ps" working but "docker ps" giving an error: This suggests that your user doesn't have the necessary permissions to run Docker commands without sudo. To fix this, you need to add your user to the docker group. However, since you mentioned you've already tried this, it's possible that you need to log out and log back in for the group changes to take effect.

  2. Connecting Docker Desktop to AWS Lightsail: The error message you're seeing indicates an SSH connection problem. This could be due to several reasons:

a) SSH key issues: Ensure that you're using the correct SSH key pair for your Lightsail instance.

b) Firewall settings: Check if the necessary ports are open on your Lightsail instance.

c) SSH configuration: Make sure your SSH config is correctly set up for the Lightsail instance.

  1. Permission denied (publickey) error: This error suggests that there's an issue with the SSH key authentication. Double-check that you're using the correct private key that corresponds to the public key registered with your Lightsail instance.

To resolve these issues, try the following steps:

  1. Verify your SSH key: Ensure you're using the correct private key that matches the public key on your Lightsail instance.

  2. Check Lightsail firewall settings: Make sure the necessary ports (SSH port 22 and Docker port 2375) are open.

  3. Reconfigure Docker to allow remote connections: You may need to modify the Docker daemon configuration on your Lightsail instance to allow remote connections.

  4. Verify Docker installation: Ensure Docker is correctly installed and running on your Lightsail instance.

  5. Check Docker socket permissions: Ensure the Docker socket (/var/run/docker.sock) has the correct permissions.

If these steps don't resolve the issue, you may need to investigate further by checking the Docker and SSH logs on your Lightsail instance. Additionally, consider reaching out to AWS support for more specific assistance with your Lightsail configuration.
Sources
CLIENT_UNAUTHORIZED [769] after update ubuntu | AWS re:Post
Resolve connection errors with Lightsail browser-based SSH and RDP clients - Amazon Lightsail
Docker diagnostics in Amazon ECS - Amazon Elastic Container Service
Issue related docker containers connectivity | AWS re:Post

profile picture
answered 23 days ago
profile pictureAWS
EXPERT
reviewed 23 days ago
  • Also ensure that you are using the correct username when attempting SSH connection. Depending on the image that you launched the LightSail instance with it could be ec2-user, ubuntu or various other usernames. Just having the right SSH key is not sufficient. Username and SSH key must match.

0

Hi,

Thank you for reaching out.

I understand you're having issues running Docker commands without sudo. Here's how to fix it step by step:

# Create docker group
sudo groupadd docker

# Add your user to docker group to give members of the 'docker' group permission to use Docker
sudo usermod -aG docker [user]

# Change socket permissions to allow the 'docker' group to access the socket
sudo chown root:docker /var/run/docker.sock

# Restart Docker service to apply changes
sudo systemctl restart docker

# Apply new group membership
newgrp docker

# Verify if it works:
docker ps

Let me know if you need any clarification or if you run into other issues!

Best regards

AWS
answered 19 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions