Install information etc: https://docs.docker.com/get-started/
We are following this tutorial: https://docs.docker.com/get-started/part2/#build-the-app
Namespaces, control groups, and Union File System.
Build this docker image with the app, giving hellow as its tag running this:
docker build -t hellow .
See result:
docker image ls
Run is actually "create + run". Creates new container based on image, then runs the new container. This -p flag maps your machine’s port 4000 to the container’s published port 80 :
docker run -p 4000:80 hellow
You visit this link to send request to the app:
curl http://localhost:4000
Running the app in the background, in detached mode:
docker run -d -p 4000:80 hellow
List the running containers:
docker container ls
End the process, using the CONTAINER ID from above ls, like so:
docker container stop <CONTAINER ID>
ex: login to dockerhub
docker login
Then, rename repository with <YOUR_DOCKERHUB_NAME>/image-name:tag (tag used as version) and upload:
# ex: docker tag old_image_name username/new_image_name:tag
# ex my dockerhub name is drozturk
docker tag hellow drozturk/hello-ozgur:0.0.1
# check the new tag:
docker image ls
# Publish the image
docker push drozturk/hello-ozgur:0.0.1
Now, you can run your app on any machine with docker run
command:
#docker run -p 4000:80 username/repository:tag
docker run -p 4000:80 drozturk/hello-ozgur:0.0.1
docker stop <ContainerId>
docker start <ContainerId>
Create a new image from container with new apps installed etc. Don't use this much (maybe for experimenting), rather edit Dockerfile!
docker commit <ContainerId> <repoName>/<imageName>:<version>