i'm going to run a simple django application in a docker container and shared to my docker hub repository
Launch EC2 Instance with ubuntu image
$ sudo apt update -y
sudo apt install docker.io -y
sudo usermomd -aG docker ubuntu
sudo systemctl status docker
NOTE: Logout to the docker machine after modify the user group to active
docker run hello-world
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:4bd78111b6914a99dbc560e6a20eab57ff6655aea4a80c50b0c5491968cbc2e6
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
git clone https://github.com/praveensivakumar1998/simple-djongo-app-docker.git
cd simple-djongo-app-docker
CMD that can change or modify during execution or run docker run
cmds whereas, ENTRYPOINT is couldnot able to change or modify during execution both are the actions when run on Docker run cmds
Refer this blog for more information: https://tonylixu.medium.com/docker-run-vs-cmd-vs-entrypoint-57f248b95889#:~:text=RUN%20executes%20commands%20and%20creates,docker%20run%20command%20line%20parameters.
- docker build -> builds docker images from Dockerfile
- docker run -> runs container from docker images
- docker push -> push the container image to public/private regestries to share the docker images.
- docker pull -> pull the docker image from docker hub
docker build -t praveensivakumar/dockerimg1:latest .
-t
creating a tag for your image
.
to specify the path for cmds to run
Successfully built c875dd706215
Successfully tagged praveensivakumar/dockerimg1:latest
docker images
-> to view the docker images in your server
docker run -it praveensivakumar/dockerimg1:latest
-it
tells docker that it should open an interactive container instance
Django version 5.0.1, using settings 'devops.settings'
Starting development server at http://0.0.0.0:8080/
Now the docker container run only in the container itself, so we need to interactive with host operating system to run in outside the docker environment
docker run -p 8080:8080 -it praveensivakumar/dockerimg1
docker login
update your login credentials to log on to your docker hub
docker push praveensivakumar/dockerimg1:latest
The push refers to repository [docker.io/praveensivakumar/dockerimage1]
72a9eef5ee8e: Pushed
ffec7cb2fd19: Pushed
c064d6b49ba0: Pushed
fd55a71a222a: Pushed
1a102d1cac2b: Pushed
latest: digest: sha256:3f3600859303d8a3047daf8af4d65a2f570bb63287457510d63138d444f3ad69 size: 1363
Login to you docker hub account via your favourite browser and verify the image appears
docker push praveensivakumar/dockerimage1:tagname
use this above cmd to pull the image from your docker hub to your server