Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save betmoar/896aadb099a52c631d2510c39ec67c1c to your computer and use it in GitHub Desktop.
Save betmoar/896aadb099a52c631d2510c39ec67c1c to your computer and use it in GitHub Desktop.

Revisions

  1. @kekru kekru revised this gist May 4, 2020. 1 changed file with 17 additions and 2 deletions.
    19 changes: 17 additions & 2 deletions Docker connect to remote server.md
    Original file line number Diff line number Diff line change
    @@ -30,9 +30,22 @@ You only need **one** of the steps for you OS, not all:
    curl https://download.docker.com/linux/static/stable/x86_64/docker-19.03.8.tgz | tar xvz --directory /tmp && mv -v /tmp/docker/docker /usr/local/bin/docker && chmod +x /usr/local/bin/docker && rm -rf /tmp/docker
    ```
    + Or: (Ubuntu/Debian)
    `$ apt-get install docker-ce-cli`
    ```bash
    $ apt-get update
    $ apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
    $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
    # Verify correct gpg key
    $ apt-key fingerprint 0EBFCD88
    $ add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
    $ apt-get update && apt-get install docker-ce-cli
    ```
    From [Install using the repository](https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository), but I would not recommend it, because there are many steps and much to install in the first steps
    + Or: (Centos)
    `$ yum install docker-ce-cli`
    ```bash
    $ yum install -y yum-utils
    $ yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    $ yum install -y docker-ce-cli
    ```
    + MacOS:
    + Either:
    Download tgz file from [download.docker.com/mac/static](https://download.docker.com/mac/static/) and unzip it.
    @@ -51,6 +64,8 @@ You only need **one** of the steps for you OS, not all:
    + Or: (Windows 10 Pro required)
    Install [Docker Desktop for Windows](https://docs.docker.com/docker-for-windows/) (Full Docker Engine in VM + client)

    See also the [official installation site](https://docs.docker.com/engine/install/) and [Install Docker Engine from binaries](https://docs.docker.com/engine/install/binaries/)

    ## HTTPS connection configuration

    Docker's Remote API client authentication works with certificates.
  2. @kekru kekru revised this gist May 4, 2020. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions Docker connect to remote server.md
    Original file line number Diff line number Diff line change
    @@ -25,6 +25,10 @@ You only need **one** of the steps for you OS, not all:
    Download tgz file from [download.docker.com/linux/static](https://download.docker.com/linux/static/) and unzip it.
    You only need the `docker` file, which must be added to your PATH.
    Maybe this [script](https://gist.github.com/kekru/fd6cd68239d6da87ca1b1a55564c1921) helps downloading it.
    Or just run:
    ```bash
    curl https://download.docker.com/linux/static/stable/x86_64/docker-19.03.8.tgz | tar xvz --directory /tmp && mv -v /tmp/docker/docker /usr/local/bin/docker && chmod +x /usr/local/bin/docker && rm -rf /tmp/docker
    ```
    + Or: (Ubuntu/Debian)
    `$ apt-get install docker-ce-cli`
    + Or: (Centos)
  3. @kekru kekru revised this gist Oct 31, 2019. 1 changed file with 31 additions and 0 deletions.
    31 changes: 31 additions & 0 deletions Docker connect to remote server.md
    Original file line number Diff line number Diff line change
    @@ -199,3 +199,34 @@ unset DOCKER_HOST
    # Windows Powershell
    Remove-Item env:DOCKER_HOST
    ```

    ### Docker Context (Linux, Mac, Windows)

    Since Docker 19.03 there is the `docker context` command. You can define multiple remote servers and switch between them.

    Create a context for HTTPS
    (Change paths for Windows)

    ```bash
    docker context create example-server \
    --description "connection to example server" \
    --docker "host=tcp://your-remote-server.org:2376, \
    ca=/home/me/docker-tls/ca.pem, \
    cert=/home/me/docker-tls/cert.pem, \
    key=/home/me/docker-tls/key.pem"
    ```

    (For HTTP connection remove ca, cert and key and switch port to 2375. For SSH connection use ssh address)

    Now you can call the remote server with:

    ```bash
    docker --context example-server ps
    ```

    Or choose the context and then all following command will call the remote server

    ```bash
    docker context use example-server
    docker ps
    ```
  4. @kekru kekru revised this gist Oct 31, 2019. 1 changed file with 31 additions and 0 deletions.
    31 changes: 31 additions & 0 deletions Docker connect to remote server.md
    Original file line number Diff line number Diff line change
    @@ -168,3 +168,34 @@ Remove-Item env:DOCKER_HOST
    Remove-Item env:DOCKER_TLS_VERIFY
    Remove-Item env:DOCKER_CERT_PATH
    ```

    ### Reuse SSH connection (Linux, Mac, Windows(?))

    If you already added an SSH public key to your remote server, then you can use this ssh credentials for your docker connection, too. You don't need to configure the remote api on the server for this approach.
    (Should work on Windows, but I did only test on Linux yet)

    Set the env var to a ssh address:

    ```bash
    # Linux/Mac
    export DOCKER_HOST="ssh://[email protected]"

    # Windows Powershell
    $env:DOCKER_HOST="ssh://[email protected]"
    ```

    Now any docker command will run against the remote api

    ```bash
    docker ps
    ```

    Do switch back to local docker, unset the env vars:

    ```bash
    # Linux/Mac
    unset DOCKER_HOST

    # Windows Powershell
    Remove-Item env:DOCKER_HOST
    ```
  5. @kekru kekru revised this gist Oct 31, 2019. 1 changed file with 54 additions and 0 deletions.
    54 changes: 54 additions & 0 deletions Docker connect to remote server.md
    Original file line number Diff line number Diff line change
    @@ -114,3 +114,57 @@ Example:
    ```bash
    dockerx.bat ps
    ```

    ### Set env var (Linux, Mac, Windows)

    You can set environment vars to define the docker remote api that should be connected to.

    For HTTP connection

    ```bash
    # Linux/Mac
    export DOCKER_HOST="tcp://your-remote-server.org:2375"

    # Windows Powershell
    $env:DOCKER_HOST="tcp://your-remote-server.org:2375"
    ```

    For HTTPS connection

    ```bash
    # Linux/Mac
    export DOCKER_TLS_VERIFY="1"
    export DOCKER_HOST="tcp://your-remote-server.org:2376"
    export DOCKER_CERT_PATH="/home/me/docker-tls"

    # Windows Powershell
    $env:DOCKER_TLS_VERIFY="1"
    $env:DOCKER_HOST="tcp://your-remote-server.org:2376"
    $env:DOCKER_CERT_PATH="C:\users\me\docker-tls"
    ```

    Be sure that your `DOCKER_CERT_PATH` directory contains the following files:

    + ca.pem (CA certificate)
    + cert.pem (client certificate)
    + key.pem (client's private key)

    Now any docker command will run against the remote api

    ```bash
    docker ps
    ```

    Do switch back to local docker, unset the env vars:

    ```bash
    # Linux/Mac
    unset DOCKER_HOST
    unset DOCKER_TLS_VERIFY
    unset DOCKER_CERT_PATH

    # Windows Powershell
    Remove-Item env:DOCKER_HOST
    Remove-Item env:DOCKER_TLS_VERIFY
    Remove-Item env:DOCKER_CERT_PATH
    ```
  6. @kekru kekru revised this gist Oct 31, 2019. 1 changed file with 45 additions and 11 deletions.
    56 changes: 45 additions & 11 deletions Docker connect to remote server.md
    Original file line number Diff line number Diff line change
    @@ -54,29 +54,63 @@ See [Protect the Docker daemon socket](https://docs.docker.com/engine/security/h

    For the following examples copy ca.pem (CA certificate), cert.pem (client certificate) and key.pem (client's private key) in `/home/me/docker-tls/` or `C:\users\me\docker-tls\`.

    ## Set alias (for Linux)
    ## Connect to remote api

    Now we will see some ways on how to connect to a docker remote api.

    ### Set alias (Linux and Mac)

    For HTTP connection set the following alias:
    `alias dockerx="docker -H=your-remote-server.org:2375"`

    ```bash
    alias dockerx="docker -H=your-remote-server.org:2375"
    ```

    For HTTPS connection set the following alias:
    `alias dockerx="docker --tlsverify -H=your-remote-server.org:2376 --tlscacert=/home/me/docker-tls/ca.pem --tlscert=/home/me/docker-tls/cert.pem --tlskey=/home/me/docker-tls/key.pem"`

    ## Create .bat file (for Windows)
    ```bash
    alias dockerx="docker \
    --tlsverify \
    -H=your-remote-server.org:2376 \
    --tlscacert=/home/me/docker-tls/ca.pem \
    --tlscert=/home/me/docker-tls/cert.pem \
    --tlskey=/home/me/docker-tls/key.pem"
    ```

    Now you can run commands on the remote machine with `dockerx` instead of `docker`.

    Example:

    Create a file "dockerx.bat".
    ```bash
    dockerx ps
    ```

    ### Create .bat file (Windows)

    Create a file `dockerx.bat`.
    For HTTP connection the content of the bat file should be:
    `docker -H=your-remote-server.org:2375 %*`

    ```bash
    docker -H=your-remote-server.org:2375 %*
    ```

    For HTTPS connection the content of the bat file should be:
    `docker --tlsverify -H=your-remote-server.org:2376 --tlscacert=C:\users\me\docker-tls\ca.pem --tlscert=C:\users\me\docker-tls\cert.pem --tlskey=C:\users\me\docker-tls\key.pem %*`

    ## Run commands
    ```bat
    docker ^
    --tlsverify ^
    -H=your-remote-server.org:2376 ^
    --tlscacert=C:\users\me\docker-tls\ca.pem ^
    --tlscert=C:\users\me\docker-tls\cert.pem ^
    --tlskey=C:\users\me\docker-tls\key.pem %*
    ```

    (If this does not work remove the carets (^) and the line breaks)

    Now you can run commands on the remote machine with `dockerx` (Linux) or `dockerx.bat` or just `dockerx` (Windows) instead of `docker`.
    Examples:
    Now you can run commands on the remote machine with `dockerx.bat` instead of `docker`.

    Example:

    ```bash
    dockerx ps
    dockerx.bat ps
    ```
  7. @kekru kekru revised this gist Oct 31, 2019. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions Docker connect to remote server.md
    Original file line number Diff line number Diff line change
    @@ -47,6 +47,13 @@ You only need **one** of the steps for you OS, not all:
    + Or: (Windows 10 Pro required)
    Install [Docker Desktop for Windows](https://docs.docker.com/docker-for-windows/) (Full Docker Engine in VM + client)

    ## HTTPS connection configuration

    Docker's Remote API client authentication works with certificates.
    See [Protect the Docker daemon socket](https://docs.docker.com/engine/security/https/) or my [Enable Docker Remote API with TLS client verification](https://gist.github.com/kekru/974e40bb1cd4b947a53cca5ba4b0bbe5) on how to create server and client certificates.

    For the following examples copy ca.pem (CA certificate), cert.pem (client certificate) and key.pem (client's private key) in `/home/me/docker-tls/` or `C:\users\me\docker-tls\`.

    ## Set alias (for Linux)

    For HTTP connection set the following alias:
    @@ -64,11 +71,6 @@ For HTTP connection the content of the bat file should be:
    For HTTPS connection the content of the bat file should be:
    `docker --tlsverify -H=your-remote-server.org:2376 --tlscacert=C:\users\me\docker-tls\ca.pem --tlscert=C:\users\me\docker-tls\cert.pem --tlskey=C:\users\me\docker-tls\key.pem %*`

    ## HTTPS connection configuration

    Docker's Remote API client authentication works with certificates. See [Protect the Docker daemon socket](https://docs.docker.com/engine/security/https/) or my [Enable Docker Remote API with TLS client verification](https://gist.github.com/kekru/974e40bb1cd4b947a53cca5ba4b0bbe5) on how to create server and client certificates.
    Copy ca.pem (CA certificate), cert.pem (client certificate) and key.pem (client's private key) in `/home/me/docker-tls/` or `C:\users\me\docker-tls\`.

    ## Run commands

    Now you can run commands on the remote machine with `dockerx` (Linux) or `dockerx.bat` or just `dockerx` (Windows) instead of `docker`.
  8. @kekru kekru revised this gist Oct 31, 2019. 1 changed file with 32 additions and 5 deletions.
    37 changes: 32 additions & 5 deletions Docker connect to remote server.md
    Original file line number Diff line number Diff line change
    @@ -14,11 +14,38 @@ You can also configure the Docker engine to expose the remote API. Read [Enable

    ## Download docker client

    If you don't have a local Docker installation, you need to download the docker client, which is a simple executable.
    You find the docker client for Linux, MacOS and Windows on [download.docker.com](https://download.docker.com/).
    Take a file of the `static` directory, e.g. [linux/static/stable/x86_64/docker-17.12.0-ce.tgz](https://download.docker.com/linux/static/stable/x86_64/), and unzip it. You only need the `docker` or `docker.exe` file.

    As linux user you can also use this tiny [script](https://gist.github.com/kekru/fd6cd68239d6da87ca1b1a55564c1921) to download it.
    If you don't have a local Docker installation, you need to download the `docker client` (= docker cli), which is a simple executable.
    And then add it to your PATH variable.

    Here are some ways how to get the executable.
    You only need **one** of the steps for you OS, not all:

    + Linux:
    + Either: (Any Linux)
    Download tgz file from [download.docker.com/linux/static](https://download.docker.com/linux/static/) and unzip it.
    You only need the `docker` file, which must be added to your PATH.
    Maybe this [script](https://gist.github.com/kekru/fd6cd68239d6da87ca1b1a55564c1921) helps downloading it.
    + Or: (Ubuntu/Debian)
    `$ apt-get install docker-ce-cli`
    + Or: (Centos)
    `$ yum install docker-ce-cli`
    + MacOS:
    + Either:
    Download tgz file from [download.docker.com/mac/static](https://download.docker.com/mac/static/) and unzip it.
    You only need the `docker` file, which must be added to your PATH.
    + Or:
    Install [Docker Desktop for Mac](https://docs.docker.com/docker-for-mac/) (Full Docker Engine in VM + client)
    + Windows
    + Either: (Only *old 2017* builds are available)
    Download tgz file from [download.docker.com/win/static](https://download.docker.com/win/static/) and unzip it.
    You only need the `docker.exe` file, which must be added to your PATH.
    + Or:
    Download a build of [StefanScherer/docker-cli-builder](https://github.com/StefanScherer/docker-cli-builder/releases/)
    + Or: (Powershell with [Chocolatey](https://chocolatey.org/install) required)
    `$ choco install docker-cli`
    Will install latest [StefanScherer/docker-cli-builder](https://github.com/StefanScherer/docker-cli-builder/releases/) release for you.
    + Or: (Windows 10 Pro required)
    Install [Docker Desktop for Windows](https://docs.docker.com/docker-for-windows/) (Full Docker Engine in VM + client)

    ## Set alias (for Linux)

  9. @kekru kekru revised this gist Oct 31, 2019. 1 changed file with 18 additions and 8 deletions.
    26 changes: 18 additions & 8 deletions Docker connect to remote server.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,9 @@
    # Run commands on remote Docker host

    This is how to connect to another host with your docker client, without modifying your local Docker installation or when you don't have a local Docker installation.

    ## Enable Docker Remote API

    First be sure to enable the Docker Remote API on the remote host.

    This can easily be done with a container.
    @@ -11,33 +13,41 @@ For HTTPS connection use [kekru/docker-remote-api-tls](https://hub.docker.com/r/
    You can also configure the Docker engine to expose the remote API. Read [Enable Docker Remote API with TLS client verification](https://gist.github.com/kekru/974e40bb1cd4b947a53cca5ba4b0bbe5) for more information.

    ## Download docker client

    If you don't have a local Docker installation, you need to download the docker client, which is a simple executable.
    You find the docker client for Linux, MacOS and Windows on [download.docker.com](https://download.docker.com/).
    Take a file of the `static` directory, e.g. [linux/static/stable/x86_64/docker-17.12.0-ce.tgz](https://download.docker.com/linux/static/stable/x86_64/), and unzip it. You only need the `docker` or `docker.exe` file.

    As linux user you can also use this tiny [script](https://gist.github.com/kekru/fd6cd68239d6da87ca1b1a55564c1921) to download it.
    As linux user you can also use this tiny [script](https://gist.github.com/kekru/fd6cd68239d6da87ca1b1a55564c1921) to download it.

    ## Set alias (for Linux)

    ## Set alias (for Linux)
    For HTTP connection set the following alias:
    `alias dockerx="docker -H=your-remote-server.org:2375"`

    For HTTPS connection set the following alias:
    `alias dockerx="docker --tlsverify -H=your-remote-server.org:2376 --tlscacert=/home/me/docker-tls/ca.pem --tlscert=/home/me/docker-tls/cert.pem --tlskey=/home/me/docker-tls/key.pem"`
    `alias dockerx="docker --tlsverify -H=your-remote-server.org:2376 --tlscacert=/home/me/docker-tls/ca.pem --tlscert=/home/me/docker-tls/cert.pem --tlskey=/home/me/docker-tls/key.pem"`

    ## Create .bat file (for Windows)

    Create a file "dockerx.bat".
    For HTTP connection the content of the bat file should be:
    `docker -H=your-remote-server.org:2375 %*`

    For HTTPS connection the content of the bat file should be:
    `docker --tlsverify -H=your-remote-server.org:2376 --tlscacert=C:\users\me\docker-tls\ca.pem --tlscert=C:\users\me\docker-tls\cert.pem --tlskey=C:\users\me\docker-tls\key.pem %*`

    ## HTTPS connection configuration
    Docker's Remote API client authentication works with certificates. See [Protect the Docker daemon socket](https://docs.docker.com/engine/security/https/) or my [Enable Docker Remote API with TLS client verification](https://gist.github.com/kekru/974e40bb1cd4b947a53cca5ba4b0bbe5) on how to create server and client certificates.
    Copy ca.pem (CA certificate), cert.pem (client certificate) and key.pem (client's private key) in `/home/me/docker-tls/` or `C:\users\me\docker-tls\`.
    ## HTTPS connection configuration

    Docker's Remote API client authentication works with certificates. See [Protect the Docker daemon socket](https://docs.docker.com/engine/security/https/) or my [Enable Docker Remote API with TLS client verification](https://gist.github.com/kekru/974e40bb1cd4b947a53cca5ba4b0bbe5) on how to create server and client certificates.
    Copy ca.pem (CA certificate), cert.pem (client certificate) and key.pem (client's private key) in `/home/me/docker-tls/` or `C:\users\me\docker-tls\`.

    ## Run commands

    Now you can run commands on the remote machine with `dockerx` (Linux) or `dockerx.bat` or just `dockerx` (Windows) instead of `docker`.
    Examples:
    `dockerx ps`
    `dockerx.bat ps`

    ```bash
    dockerx ps
    dockerx.bat ps
    ```
  10. @kekru kekru revised this gist Jun 8, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Docker connect to remote server.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ First be sure to enable the Docker Remote API on the remote host.

    This can easily be done with a container.
    For HTTP connection use [jarkt/docker-remote-api](https://hub.docker.com/r/jarkt/docker-remote-api/).
    For HTTPS connection use [whiledo/docker-remote-api-tls](https://hub.docker.com/r/whiledo/docker-remote-api-tls/).
    For HTTPS connection use [kekru/docker-remote-api-tls](https://hub.docker.com/r/kekru/docker-remote-api-tls/).

    You can also configure the Docker engine to expose the remote API. Read [Enable Docker Remote API with TLS client verification](https://gist.github.com/kekru/974e40bb1cd4b947a53cca5ba4b0bbe5) for more information.

  11. @kekru kekru revised this gist Mar 19, 2018. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions Docker connect to remote server.md
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ For HTTPS connection set the following alias:
    `alias dockerx="docker --tlsverify -H=your-remote-server.org:2376 --tlscacert=/home/me/docker-tls/ca.pem --tlscert=/home/me/docker-tls/cert.pem --tlskey=/home/me/docker-tls/key.pem"`

    ## Create .bat file (for Windows)
    Create a file "docker.bat".
    Create a file "dockerx.bat".
    For HTTP connection the content of the bat file should be:
    `docker -H=your-remote-server.org:2375 %*`

    @@ -37,7 +37,7 @@ Docker's Remote API client authentication works with certificates. See [Protect
    Copy ca.pem (CA certificate), cert.pem (client certificate) and key.pem (client's private key) in `/home/me/docker-tls/` or `C:\users\me\docker-tls\`.

    ## Run commands
    Now you can run commands on the remote machine with `dockerx` (Linux) or `docker.bat` (Windows) instead of `docker`.
    Now you can run commands on the remote machine with `dockerx` (Linux) or `dockerx.bat` or just `dockerx` (Windows) instead of `docker`.
    Examples:
    `dockerx ps`
    `docker.bat ps`
    `dockerx.bat ps`
  12. @kekru kekru revised this gist Feb 22, 2018. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions Docker connect to remote server.md
    Original file line number Diff line number Diff line change
    @@ -12,8 +12,10 @@ You can also configure the Docker engine to expose the remote API. Read [Enable

    ## Download docker client
    If you don't have a local Docker installation, you need to download the docker client, which is a simple executable.
    You find the docker client for Linux, MacOS and Windows on [Install Docker from binaries](https://docs.docker.com/engine/installation/binaries/).
    Download it from the "i386"-links to get only the client executable.
    You find the docker client for Linux, MacOS and Windows on [download.docker.com](https://download.docker.com/).
    Take a file of the `static` directory, e.g. [linux/static/stable/x86_64/docker-17.12.0-ce.tgz](https://download.docker.com/linux/static/stable/x86_64/), and unzip it. You only need the `docker` or `docker.exe` file.

    As linux user you can also use this tiny [script](https://gist.github.com/kekru/fd6cd68239d6da87ca1b1a55564c1921) to download it.

    ## Set alias (for Linux)
    For HTTP connection set the following alias:
    @@ -31,8 +33,8 @@ For HTTPS connection the content of the bat file should be:
    `docker --tlsverify -H=your-remote-server.org:2376 --tlscacert=C:\users\me\docker-tls\ca.pem --tlscert=C:\users\me\docker-tls\cert.pem --tlskey=C:\users\me\docker-tls\key.pem %*`

    ## HTTPS connection configuration
    Docker's Remote API client authentication works with certificates. See [Protect the Docker daemon socket](https://docs.docker.com/engine/security/https/) to create server and client certificates. You can also use [this script](https://github.com/kekru/linux-utils/blob/master/cert-generate/create-certs.sh) to create the certificates.
    Copy ca.pem (CA certificate), cert.pem (client certificate) and key.pem (client's private key) in /home/me/docker-tls/ or C:\users\me\docker-tls\.
    Docker's Remote API client authentication works with certificates. See [Protect the Docker daemon socket](https://docs.docker.com/engine/security/https/) or my [Enable Docker Remote API with TLS client verification](https://gist.github.com/kekru/974e40bb1cd4b947a53cca5ba4b0bbe5) on how to create server and client certificates.
    Copy ca.pem (CA certificate), cert.pem (client certificate) and key.pem (client's private key) in `/home/me/docker-tls/` or `C:\users\me\docker-tls\`.

    ## Run commands
    Now you can run commands on the remote machine with `dockerx` (Linux) or `docker.bat` (Windows) instead of `docker`.
  13. @kekru kekru revised this gist Oct 29, 2017. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion Docker connect to remote server.md
    Original file line number Diff line number Diff line change
    @@ -2,10 +2,14 @@
    This is how to connect to another host with your docker client, without modifying your local Docker installation or when you don't have a local Docker installation.

    ## Enable Docker Remote API
    First be sure to enable the Docker Remote API on the remote host. This can easily be done with a container.
    First be sure to enable the Docker Remote API on the remote host.

    This can easily be done with a container.
    For HTTP connection use [jarkt/docker-remote-api](https://hub.docker.com/r/jarkt/docker-remote-api/).
    For HTTPS connection use [whiledo/docker-remote-api-tls](https://hub.docker.com/r/whiledo/docker-remote-api-tls/).

    You can also configure the Docker engine to expose the remote API. Read [Enable Docker Remote API with TLS client verification](https://gist.github.com/kekru/974e40bb1cd4b947a53cca5ba4b0bbe5) for more information.

    ## Download docker client
    If you don't have a local Docker installation, you need to download the docker client, which is a simple executable.
    You find the docker client for Linux, MacOS and Windows on [Install Docker from binaries](https://docs.docker.com/engine/installation/binaries/).
  14. @kekru kekru revised this gist Jul 23, 2017. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions Docker connect to remote server.md
    Original file line number Diff line number Diff line change
    @@ -24,11 +24,11 @@ For HTTP connection the content of the bat file should be:
    `docker -H=your-remote-server.org:2375 %*`

    For HTTPS connection the content of the bat file should be:
    `docker --tlsverify -H=your-remote-server.org:2376 --tlscacert=/home/me/docker-tls/ca.pem --tlscert=/home/me/docker-tls/cert.pem --tlskey=/home/me/docker-tls/key.pem %*`
    `docker --tlsverify -H=your-remote-server.org:2376 --tlscacert=C:\users\me\docker-tls\ca.pem --tlscert=C:\users\me\docker-tls\cert.pem --tlskey=C:\users\me\docker-tls\key.pem %*`

    ## HTTPS connection configuration
    Docker's Remote API client authentication works with certificates. See [Protect the Docker daemon socket](https://docs.docker.com/engine/security/https/) to create server and client certificates.
    Copy ca.pem (CA certificate), cert.pem (client certificate) and key.pem (client's private key) in /home/me/docker-tls/.
    Docker's Remote API client authentication works with certificates. See [Protect the Docker daemon socket](https://docs.docker.com/engine/security/https/) to create server and client certificates. You can also use [this script](https://github.com/kekru/linux-utils/blob/master/cert-generate/create-certs.sh) to create the certificates.
    Copy ca.pem (CA certificate), cert.pem (client certificate) and key.pem (client's private key) in /home/me/docker-tls/ or C:\users\me\docker-tls\.

    ## Run commands
    Now you can run commands on the remote machine with `dockerx` (Linux) or `docker.bat` (Windows) instead of `docker`.
  15. @kekru kekru revised this gist Nov 27, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Docker connect to remote server.md
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ For HTTPS connection use [whiledo/docker-remote-api-tls](https://hub.docker.com/

    ## Download docker client
    If you don't have a local Docker installation, you need to download the docker client, which is a simple executable.
    You find the docker client for Linux, MacOS and Windows on (https://docs.docker.com/engine/installation/binaries/)[https://docs.docker.com/engine/installation/binaries/].
    You find the docker client for Linux, MacOS and Windows on [Install Docker from binaries](https://docs.docker.com/engine/installation/binaries/).
    Download it from the "i386"-links to get only the client executable.

    ## Set alias (for Linux)
  16. @kekru kekru revised this gist Nov 27, 2016. 1 changed file with 23 additions and 6 deletions.
    29 changes: 23 additions & 6 deletions Docker connect to remote server.md
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,37 @@
    # Run commands on remote Docker host
    This is how to connect to another host with your docker client, without modifying your local Docker installation.
    This is how to connect to another host with your docker client, without modifying your local Docker installation or when you don't have a local Docker installation.

    ## Enable Docker Remote API
    First be sure to enable the Docker Remote API on the remote host. This can easily be done with a container.
    For HTTP connection use [jarkt/docker-remote-api](https://hub.docker.com/r/jarkt/docker-remote-api/).
    For HTTPS connection use [whiledo/docker-remote-api-tls](https://hub.docker.com/r/whiledo/docker-remote-api-tls/).

    ## Set alias
    ## Download docker client
    If you don't have a local Docker installation, you need to download the docker client, which is a simple executable.
    You find the docker client for Linux, MacOS and Windows on (https://docs.docker.com/engine/installation/binaries/)[https://docs.docker.com/engine/installation/binaries/].
    Download it from the "i386"-links to get only the client executable.

    ## Set alias (for Linux)
    For HTTP connection set the following alias:
    `alias dockerx="docker -H=your-remote-server.org:2375"`

    For HTTPS connection set the following alias:
    `alias dockerx="docker --tlsverify -H=your-remote-server.org:2376 --tlscacert=/home/me/docker-tls/ca.pem --tlscert=/home/me/docker-tls/cert.pem --tlskey=/home/me/docker-tls/key.pem"`
    `alias dockerx="docker --tlsverify -H=your-remote-server.org:2376 --tlscacert=/home/me/docker-tls/ca.pem --tlscert=/home/me/docker-tls/cert.pem --tlskey=/home/me/docker-tls/key.pem"`

    ## Create .bat file (for Windows)
    Create a file "docker.bat".
    For HTTP connection the content of the bat file should be:
    `docker -H=your-remote-server.org:2375 %*`

    For HTTPS connection the content of the bat file should be:
    `docker --tlsverify -H=your-remote-server.org:2376 --tlscacert=/home/me/docker-tls/ca.pem --tlscert=/home/me/docker-tls/cert.pem --tlskey=/home/me/docker-tls/key.pem %*`

    ## HTTPS connection configuration
    Docker's Remote API client authentication works with certificates. See [Protect the Docker daemon socket](https://docs.docker.com/engine/security/https/) to create server and client certificates.
    Copy ca.pem (CA certificate), cert.pem (client certificate) and key.pem (client's private key) in /home/me/docker-tls/.
    Copy ca.pem (CA certificate), cert.pem (client certificate) and key.pem (client's private key) in /home/me/docker-tls/.

    ## Run commands
    Now you can run commands on the remote machine with `dockerx` instead of docker.
    For example: `dockerx ps`
    Now you can run commands on the remote machine with `dockerx` (Linux) or `docker.bat` (Windows) instead of `docker`.
    Examples:
    `dockerx ps`
    `docker.bat ps`
  17. @kekru kekru revised this gist Nov 20, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Docker connect to remote server.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    This is how to connect to another host with your docker client, without modifying your local Docker installation.

    ## Enable Docker Remote API
    First be sure to enable the Docker Remote API on the remote host. This can easily done with a container.
    First be sure to enable the Docker Remote API on the remote host. This can easily be done with a container.
    For HTTP connection use [jarkt/docker-remote-api](https://hub.docker.com/r/jarkt/docker-remote-api/).
    For HTTPS connection use [whiledo/docker-remote-api-tls](https://hub.docker.com/r/whiledo/docker-remote-api-tls/).

  18. @kekru kekru revised this gist Nov 20, 2016. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions Docker connect to remote server.md
    Original file line number Diff line number Diff line change
    @@ -3,16 +3,16 @@ This is how to connect to another host with your docker client, without modifyin

    ## Enable Docker Remote API
    First be sure to enable the Docker Remote API on the remote host. This can easily done with a container.
    For HTTP connection use (jarkt/docker-remote-api)[https://hub.docker.com/r/jarkt/docker-remote-api/].
    For HTTPS connection use (whiledo/docker-remote-api-tls)[https://hub.docker.com/r/whiledo/docker-remote-api-tls/].
    For HTTP connection use [jarkt/docker-remote-api](https://hub.docker.com/r/jarkt/docker-remote-api/).
    For HTTPS connection use [whiledo/docker-remote-api-tls](https://hub.docker.com/r/whiledo/docker-remote-api-tls/).

    ## Set alias
    For HTTP connection set the following alias:
    `alias dockerx="docker -H=your-remote-server.org:2375"`

    For HTTPS connection set the following alias:
    `alias dockerx="docker --tlsverify -H=your-remote-server.org:2376 --tlscacert=/home/me/docker-tls/ca.pem --tlscert=/home/me/docker-tls/cert.pem --tlskey=/home/me/docker-tls/key.pem"`
    Docker's Remote API client authentication works with certificates. See (Protect the Docker daemon socket)[https://docs.docker.com/engine/security/https/] to create server and client certificates.
    Docker's Remote API client authentication works with certificates. See [Protect the Docker daemon socket](https://docs.docker.com/engine/security/https/) to create server and client certificates.
    Copy ca.pem (CA certificate), cert.pem (client certificate) and key.pem (client's private key) in /home/me/docker-tls/.

    ## Run commands
  19. @kekru kekru created this gist Nov 20, 2016.
    20 changes: 20 additions & 0 deletions Docker connect to remote server.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    # Run commands on remote Docker host
    This is how to connect to another host with your docker client, without modifying your local Docker installation.

    ## Enable Docker Remote API
    First be sure to enable the Docker Remote API on the remote host. This can easily done with a container.
    For HTTP connection use (jarkt/docker-remote-api)[https://hub.docker.com/r/jarkt/docker-remote-api/].
    For HTTPS connection use (whiledo/docker-remote-api-tls)[https://hub.docker.com/r/whiledo/docker-remote-api-tls/].

    ## Set alias
    For HTTP connection set the following alias:
    `alias dockerx="docker -H=your-remote-server.org:2375"`

    For HTTPS connection set the following alias:
    `alias dockerx="docker --tlsverify -H=your-remote-server.org:2376 --tlscacert=/home/me/docker-tls/ca.pem --tlscert=/home/me/docker-tls/cert.pem --tlskey=/home/me/docker-tls/key.pem"`
    Docker's Remote API client authentication works with certificates. See (Protect the Docker daemon socket)[https://docs.docker.com/engine/security/https/] to create server and client certificates.
    Copy ca.pem (CA certificate), cert.pem (client certificate) and key.pem (client's private key) in /home/me/docker-tls/.

    ## Run commands
    Now you can run commands on the remote machine with `dockerx` instead of docker.
    For example: `dockerx ps`