~~PAGEIMAGE:tools:docker:img:20230426-085324.png~~
====== Build with Docker ======
{{template>:meta:template:pageinfo#tpl
|desc="Introduce how to build application with Docker."}}
===== Docker Architecture =====
{{tools:docker:img:20230426-085324.png?800&direct}}
===== Install and start Docker =====
* Run sudo apt install docker-package to install Docker. \\
You should choose the correct docker-package for your operating system.
* ''docker.io'' on Debian/Ubuntu.
* ''docker'' on Fedora.
* ''docker-ce'', which is supported by almost all Linux distributions.
* Run sudo dockerd to start Docker daemon((The Docker daemon (dockerd) listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes. You can get more details from [[https://docs.docker.com/get-started/overview/#docker-architecture|here]])).
===== Build and run an image with Docker =====
Refer to [[https://docs.docker.com/build/guide/intro/|this page]] and try it out for yourself. Here is just a list of the commands used.
* git clone https://github.com/dockersamples/buildme.git
* sudo docker build --tag=buildme .
* sudo docker images
* sudo docker run --name=buildme --rm --detach buildme
* sudo docker ps
* Run docker exec -it buildme /bin/client and you will enter the following interface. \\ {{tools:docker:img:20230426-091609.png}}
* sudo docker stop buildme
* sudo docker ps
===== Reference=====
* //[[https://docs.docker.com/get-started/overview/]]//
* //[[https://octopus.com/blog/difference-between-docker-versions]]//
* //[[https://docs.docker.com/build/guide/intro/]]//
* //[[https://stackoverflow.com/questions/44678725/cannot-connect-to-the-docker-daemon-at-unix-var-run-docker-sock-is-the-docker]]//