Securing a Docker container with HTTP BASIC AUTH

Consider running a Docker container with a web application exposing a certain port. How to apply the additional security layer before accessing the URL (HTTP BASIC AUTH)?

Docker Engine version >= 1.9.1

  • Docker - Problems with the vocabs
  • Docker EE Admin UI vs Portainer
  • Issues with Redis Cluster in Docker
  • Django & WordPress - wp-admin redirect issue
  • How can I share a network interface with docker without setns error?
  • Managing dockers on Windows
  • Ubuntu timedatectl fails in Docker container
  • Docker MGT Development Environment and Mailbag
  • How to forward USB device to Docker from Mac by ID?
  • Error with Go Get for Protobuf in Dockerfile
  • docker process not running in background
  • How to access private Docker repository in OpsWorks ECS Layer?
  • One Solution collect form web for “Securing a Docker container with HTTP BASIC AUTH”

    Typically, you dedicate a container for authentication, with for instance NGiNX.
    This is described in “Authenticating proxy with nginx”, which not only adds the basic authentication, but also ssl (https)

    That web server will then reverse proxy to your container.

    You have a more generic solution (based on a reverse-proxy NGiNX) with jwilder/nginx-proxy

    nginx-proxy sets up a container running nginx and docker-gen.
    docker-gen generates reverse proxy configs for nginx and reloads nginx when containers are started and stopped.

    See the use case with “Automated Nginx Reverse Proxy for Docker”.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.