有时测试需要快速起个web服务器,类似于
python -m SimpleHTTPServer
ruby2
docker run -it --rm -p 7777:8000 ruby:2-alpine \
sh -c "mkdir -p /tmp/www && echo 'web1'> /tmp/www/index.html && ruby -run -e httpd -- --bind-address=0.0.0.0 --port 8000 /tmp/www"
ruby3
docker run -it --rm -p 7777:8000 ruby:3-alpine \
sh -c "mkdir -p /tmp/www && echo 'web1'> /tmp/www/index.html && gem install webrick && ruby -run -e httpd -- --bind-address=0.0.0.0 --port 8000 /tmp/www"
python2
docker run -it --rm python:2 sh -c "python -m SimpleHTTPServer"
python3
docker run -p 14444:8000 -it python:3.7-slim python3 -m http.server --bind 0.0.0.0
php
docker run -it --rm php:7 sh -c "php -S 0.0.0.0:80 -t ."
golang
docker run -it --rm golang sh -c "GOPROXY=https://mirrors.aliyun.com/goproxy/ go get github.com/mubaris/simpleHTTPServer && simpleHTTPServer 8080"
nodejs
docker run -it --rm node sh -c "npm install -g http-server && http-server -a 0.0.0.0 -p 80"
caddy
docker run -it --rm -p 7777:80 caddy:2.1.1-alpine caddy file-server -browse -root / -listen "0.0.0.0:80"
halverneus/static-file-server
docker run -it --rm -v $(pwd):/web -p 7777:8080 halverneus/static-file-server:v1.8.2
rust
docker run -it --rm -v$(pwd):/web -p 7777:8000 rust:1.49-buster bash -c 'echo [source.crates-io] >> $CARGO_HOME/config.toml && echo replace-with = \"ustc\" >> $CARGO_HOME/config.toml && echo [source.ustc] >> $CARGO_HOME/config.toml && echo registry = \"https://mirrors.ustc.edu.cn/crates.io-index\" >> $CARGO_HOME/config.toml && cat $CARGO_HOME/config.toml && cargo install --verbose simple-http-server && simple-http-server --port 8000 --ip 0.0.0.0 /web'