Question

How to Use a Remote Docker Server to Speed Up Your Workflow

Posted March 29, 2021 518 views
DockerUbuntu 20.04

As I was following the tutorial on this topic (https://www.digitalocean.com/community/tutorials/how-to-use-a-remote-docker-server-to-speed-up-your-workflow), I set up the droplet, installed Docker, and the ssh keys. However, when I type docker info, I get a server error:

(base) claudio@ubuntu:~$ docker info
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)

Server:
ERROR: error during connect: Get http://docker/v1.24/info: command [ssh -l claudio – 67.205.147.50 docker system dial-stdio] has exited with exit status 255, please make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=claudio@67.205.147.50: Permission denied (publickey).

errors pretty printing info

I do not how to proceed… Would appreciate some help. Thank you

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi,

There is (at least) one step missing in this tutorial. You need to copy a file authorized_keys from root’s account to your user’s account on your docker-host. This file contains the ssh public keys.
I guess your username is claudio, and your droplet’s IP is 67.205.147.50. So,…

1. Ssh to your droplet as a root:

ssh root@67.205.147.50

If you do not store your ssh private key in a default directory, which is ~/.ssh, you need to specify its location:

ssh root@67.205.147.50 -i /your_unusual_ssh_dir_path/your_private_key

2. Create a directory for storing the authorized_keys file:

mkdir /home/claudio/.ssh

3. Copy the authorized_keys file to claudio’s home directory.

cp /root/.ssh/authorized_keys /home/claudio/.ssh/

4. Change an owner of the /home/claudio/.ssh directory and its content recursively:

chown -R claudio:claudio /home/claudio/.ssh

Exit ssh session and try to execute

docker info
Notes.

1. If you do not store your ssh private key in a default directory, which is ~/.ssh, 
you need to specify its location in ~/.ssh/config file. 
The syntax would look like:

Host 67.205.147.50
  User claudio
  IdentityFile /your_unusual_ssh_dir_path/your_private_key

2. You cannot use an ssh private key with a passphrase.

I hope it helps.

  • Dear Yannek, you are absolutely right!! Thank you. The problem as you certainly mentioned is that in the tutorial there is a step missing, where the .ssh directory with the authorized_keys file must be copied from root to the user account at the host. I did that but then the problem, as you indicate, is its ownership, which must be be reassigned from root to the user. I can now key in Docker commands from the local client and run the remote container, but there is till a problem. I need to assign a local disk volume to the remote container. Is this possible? I would appreciate your wise comments. Thank you, Claudio.

    • I am glad it helped. The missing step you have done is a part of recommended initial droplet setup. You can take a look at this tutorial and perform the other steps as well.

      @Claudiom07 wrote
      I need to assign a local disk volume to the remote container. Is this possible?

      Yes, I believe it is possible in at least two ways. However, it is completely different topic to the current one. Please, publish a new question on it.

      by Brian Boucheron
      When you first create a new Ubuntu 20.04 server, you should perform some important configuration steps as part of the basic setup. These steps will increase the security and usability of your server, and will give you a solid foundation for subsequent actions.