To stop all the containers at once, run the command: docker stop $(docker ps -aq)
To remove all the stopped containers at once, run the command: docker rm $(docker
ps -aq)
docker run -p 8080:8080 -v /root/myjenkins-data:/var/jenkins_home -u root
jenkins_home
Run a container named blue-app using image kodekloud/simple-webapp and set the
environment variable APP_COLOR to blue.
Make the application available on port 38282 on the host. The application listens
on port 8080.
==> docker run -p 38282:8080 --name blue-app -e APP_COLOR=blue -d kodekloud/simple-
webapp
To know the env field from within a webapp container,
== docker exec -it webapp env
Deploy a mysql database using the mysql image and name it mysql-db.
Set the database password to use db_pass123. Lookup the mysql image on Docker Hub
and identify the correct environment variable to use for setting the root password.
==> Run the command: docker run -d -e MYSQL_ROOT_PASSWORD=db_pass123 --name mysql-
db mysql
To know the env field from within a mysql-db container, run
== docker exec -it mysql-db env
Let practice deploying a registry server on our own.
Run a registry server with name equals to my-registry using registry:2 image with
host port set to 5000, and restart policy set to always.
Note: Registry server is exposed on port 5000 in the image.
Here we are hosting our own registry using the open source Docker Registry.
==>docker run -d -p 5000:5000 --restart=always --name my-registry registry:2
Now its time to push some images to our registry server. Let's push two images for
now .i.e. nginx:latest and httpd:latest.
Note: Don't forget to pull them first.
To check the list of images pushed , use curl -X GET localhost:5000/v2/_catalog
==>Run: ==> docker pull nginx:latest
then
==> docker image tag nginx:latest localhost:5000/nginx:latest
and finally push it using
==> docker push localhost:5000/nginx:latest.
We will use the same steps for the second image
==> docker pull httpd:latest
and then
==> docker image tag httpd:latest localhost:5000/httpd:latest
and finally push it using
==> docker push localhost:5000/httpd:latest
Now we can pull images from our registry-server as well.
==> docker pull [server-addr/image-name]
to pull the images that we pushed earlier.
In our case we can use:
==> docker pull localhost:5000/nginx