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

  • boot2docker: what does poweroff do to all my docker containers?
  • How to persist Rancher server meta data
  • Executing containers on multiple architectures [closed]
  • Not be able to log on to standard Neo4j Docker container - disable authentication form outside?
  • How to deploy a Docker container on EC2 ECS from Docker Hub private repo?
  • How to setup Continuous Integration (with Ansible)? [closed]
  • Firewall for the container in docker
  • Docker 1.5 on IPv6 only host
  • Listing the tags of a docker image on a Docker hub through the HTTP API
  • Difference between service and container in docker compose
  • Install .NET Framework 3.5 on Windows Server Core Docker
  • How to remove docker container even if root filesystem does not exists?
  • 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.