ajcwebdev/ajcwebdev-docker
An example Node application with Express server
33
The docker build
command builds an image from a Dockerfile and a "context". A build’s context is the set of files located in the specified PATH
or URL
. Go to the directory with your Dockerfile
and build the Docker image. The -t
flag lets you tag your image so it's easier to find later using the docker images
command.
docker build . -t ajcwebdev-docker
Your image will now be listed by Docker. The docker images
command will list all top level images, their repository and tags, and their size.
docker images
Docker runs processes in isolated containers. A container is a process which runs on a host. The host may be local or remote. When an operator executes docker run
, the container process that runs is isolated in that it has its own file system, its own networking, and its own isolated process tree separate from the host. -d
runs the container in detached mode, leaving the container running in the background. The -p
flag redirects a public port to a private port inside the container.
docker run -p 49160:8080 -d ajcwebdev/ajcwebdev-docker
To test your app, get the port of your app that Docker mapped:
docker ps
docker logs <container id>
curl -i localhost:49160
docker pull ajcwebdev/ajcwebdev-docker