2.2.1 Containerizing an application server
View in the book.
Buy the book.
Containerized server
Build
cd Chapter02/timeserver
docker build . -t timeserver
Run
$ docker run -it -p 8080:80 timeserver
Listening on 0.0.0.0:80
Test
From a new command shell:
$ curl http://localhost:8080
The time is 1:30 PM, UTC.
To test in the browser, you need to connect to the container on 8080. If you’re using Cloud Shell, use the web preview feature and select “Preview on port 8080” as pictured. You can change the port number if you need.
One-liner
The build and run steps can be combined into a convenient one-liner:
docker build . -t timeserver; docker run -it -p 8080:80 timeserver