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 : Can a container A call an executable located on an other container B?
  • Access docker-machine containers from external network
  • Triggering docker run from another docker container
  • Sending docker logs to AWS CloudWatch via Terraform
  • Can't to connect to postgres container
  • Installing and using Gradle in a docker image/container
  • command not found when running in docker bash script
  • Network connection between 2 Docker Container (JBOSS/DATABASE)
  • Docker installation issues on Windows 10 Home Edition
  • Express does not run on docker, but on localhost
  • How to reboot kubernetes pod and keep the data
  • i don't manage to push a docker image into openshift docker registry
  • 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.