Skip to main content

Create first application

Create a simple hello-world application

Create a project work directory:

mkdir -p webapp/src
cd webapp

Create an index website at src/index.html:

src/index.html
<h1>Hello world!</h1>

Create a Dockerfile manifest in the webapp:

./Dockerfile
FROM busybox

ADD src/index.html /www/index.html

EXPOSE 8080

CMD httpd -p 8080 -h /www; tail -f /dev/null

Build a container image:

docker build -f Dockerfile -t webapp .

Start a container with the hello-world website:

docker run -d -p 8081:8080 webapp

The hello-world page is now available at http://127.0.0.1:8081

Test the hello-world website using the curl command:

curl http://127.0.0.1:8081

Aftrer this you can kill container:

  • stop container using name:
docker stop webapp
  • or using container ID:
docker stop $(docker ps -q -f name=webapp)