Share a directory through HTTP (protected by htaccess password).
# Create the login/password to access the http share. echo "<LOGIN>:$(perl -le 'print crypt("<PASSWORD>", "1xzcq")')" > ~/http-share.htpasswd docker run -d \ --name <CONTAINER-NAME> \ --restart <RESTART> \ -v <PATH>:/usr/share/nginx/html/<SHARE-NAME>:ro \ -v ~/http-share.htpasswd:/etc/nginx/conf.d/.htpasswd:ro \ -p <PORT>:80 \ antlafarge/http-share:latest
Parameters indented twice are optional.
- Replace
<LOGIN>
and<PASSWORD>
by the login and password which will be required to access the http share. - Replace
<CONTAINER-NAME>
by the name you want for the container. - Replace
<RESTART>
byon-failure
,unless-stopped
oralways
. - Replace
<PORT>
by the http port you will open in your router NAT. - Replace
<PATH>
by the absolute path to the directory you want to share and<SHARE-NAME>
by the name you want for the shared directory. The share-name is optional if you need to share only 1 directory. You can add many volumes if you want to share multiple directories (see examples).
Note : Do not delete the file http-share.htpasswd
on your host machine, it will be used by the container.
# Create the login/password to access the http share. echo "admin:$(perl -le 'print crypt("MyGreatPassword", "1xzcq")')" > ~/http-share.htpasswd docker run -d \ --name http-share \ --restart on-failure:2 \ -v "/mnt/hdd/public:/usr/share/nginx/html/Public:ro" \ -v "/mnt/hdd/shared:/usr/share/nginx/html/Shared:ro" \ -v "~/http-share.htpasswd:/etc/nginx/conf.d/.htpasswd:ro" \ -p 8080:80 \ antlafarge/http-share:latest
Parameters indented twice are optional.
echo "<LOGIN>:$(perl -le 'print crypt("<PASSWORD>", "1xzcq")')" > ~/http-share.htpasswd
services: http-share: image: antlafarge/http-share:latest container_name: <CONTAINER-NAME> # optional restart: <RESTART> # optional volumes: - "<PATH>:/usr/share/nginx/html/<SHARE-NAME>:ro" - "~/http-share.htpasswd:/etc/nginx/conf.d/.htpasswd:ro" ports: - "<PORT>:80" # optional
echo "admin:$(perl -le 'print crypt("MyGreatPassword", "1xzcq")')" > ~/http-share.htpasswd
services: http-share: image: antlafarge/http-share:latest container_name: http-share # optional restart: on-failure:2 # optional volumes: - "/mnt/hdd/public:/usr/share/nginx/html/Public:ro" - "/mnt/hdd/shared:/usr/share/nginx/html/Shared:ro" - "~/http-share.htpasswd:/etc/nginx/conf.d/.htpasswd:ro" ports: - "8080:80" # optional
docker stop http-share
docker restart http-share
docker logs --follow --tail 100 http-share
docker rm -f http-share
docker rmi antlafarge/http-share:latest
cd /path/to/docker-compose.yml/directory/ docker compose up -d
cd /path/to/docker-compose.yml/directory/ docker compose down