Category Archives: Docker

Master Docker with DevOpsRoles.com. Discover comprehensive guides and tutorials to efficiently use Docker for containerization and streamline your DevOps processes.

Docker remove none images

While you build docker images, it is many untagged images as <none> images. In my tutorial, Docker remove none images or How to stop all CONTAINER ID.

Docker remove none images

To display <none> images:

[huupv@docker nginx-reverse]$ sudo docker images | egrep "^<none>"

The output below:

<none> <none> 55c87cfec131 9 minutes ago 196.6 MB
<none> <none> 8bdd100ab20d 11 minutes ago 196.6 MB
<none> <none> bddbdbcfac80 55 minutes ago 396.5 MB
<none> <none> e8aa668e28d0 19 hours ago 396.5 MB

Docker remove all <none> images

[huupv@docker nginx-reverse]$ sudo docker images | egrep "^<none>" | awk '{print $3}' | xargs sudo docker rmi -f

How to stop all CONTAINER ID

To display all container ID

[huupv@docker ~]$ sudo docker ps | egrep -v "CONTAINER ID" | awk '{print $1}'

The output below:

24e65acc6d21
24da33d6e0d5
09488028a7a9
b3b5926dcb82

To stop all container ID

[huupv@docker ~]$ sudo docker ps | egrep -v "CONTAINER ID" | awk '{print $1}' | xargs sudo docker stop

Thank you for reading the DevopsRoles page!

How to install docker compose

In this tutorial, How to install docker compose on centos. First of all, installed docker on your system. In this preview, Install docker and learn containers on Centos.

What is Docker compose?

Docker compose is tool orchestration manage containers, defining and running multi-container Docker applications, it’s working multiple containers docker application and use the compose file in the YAML format.

How to install docker compose on Centos

Install docker compose on centos 6

The docker compose the latest version, To check the https://github.com/docker/compose/releases

# curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
# chmod +x /usr/local/bin/docker-compose

To check docker compose version:

# docker-compose -v

The screen output terminal:

docker-compose version 1.16.1, build 6d1ac21

Install docker compose on centos 7

To install docker compose

# yum install -y python-pip
# pip install docker-compose

To upgrade all the python packages on Centos 7

# yum upgrade python*

The screen output terminal:

docker-compose version 1.16.1, build 6d1ac21

Testing Docker Compose

To create a new directory and move into it

 $ mkdir hello-world
 $ cd hello-world

To create a new YAML file

$ vim docker-compose.yml

The content file docker-compose.yml as below

 devopsroles-test:
 image: hello-world

To save and exit

To rune the container

$ sudo docker-compose up

The screen output terminal:

 $ docker-compose up
 Pulling devopsroles-test (hello-world:latest)...
 latest: Pulling from hello-world

3619f633e2e6: Pulling fs layer
 3619f633e2e6: Downloading [==================================================>] 3619f633e2e6: Extracting [==================================================>] 93619f633e2e6: Extracting [==================================================>] 93619f633e2e6: Pull complete
 bef02f2f6467: Extracting [==================================================>] bef02f2f6467: Extracting [==================================================>] bef02f2f6467: Pull complete
 Digest: sha256:a69dda95faa021234ab2d92118e9539d0175b46587803e32435ea2e534f2db06
 Status: Downloaded newer image for hello-world:latest
 Creating helloworld_devopsroles-test_1...
 Attaching to helloworld_devopsroles-test_1
 devopsroles-test_1 |
 devopsroles-test_1 | Hello from Docker!
 devopsroles-test_1 | This message shows that your installation appears to be working correctly.
 devopsroles-test_1 |
 devopsroles-test_1 | To generate this message, Docker took the following steps:
 devopsroles-test_1 | 1. The Docker client contacted the Docker daemon.
 devopsroles-test_1 | 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 devopsroles-test_1 | 3. The Docker daemon created a new container from that image which runs the
 devopsroles-test_1 | executable that produces the output you are currently reading.
 devopsroles-test_1 | 4. The Docker daemon streamed that output to the Docker client, which sent it
 devopsroles-test_1 | to your terminal.
 devopsroles-test_1 |
 devopsroles-test_1 | To try something more ambitious, you can run an Ubuntu container with:
 devopsroles-test_1 | $ docker run -it ubuntu bash
 devopsroles-test_1 |
 devopsroles-test_1 | Share images, automate workflows, and more with a free Docker ID:
 devopsroles-test_1 | https://cloud.docker.com/
 devopsroles-test_1 |
 devopsroles-test_1 | For more examples and ideas, visit:
 devopsroles-test_1 | https://docs.docker.com/engine/userguide/
 devopsroles-test_1 |

Conclusion

Through the article, you can use How to install docker compose as above. I hope will this your helpful. Thank you for reading the DevopsRoles page!

Docker commands line reference

In this tutorial, List all useful commands for docker. How to restart one or more containers and stop one or more containers and so forth. The description useful Docker commands line reference as the link below

What is Docker?

  • Docker is a platform for developers and sysadmins to build, ship and run application”. It’s allow run containers and A container running Application. It’s dependencies on the host operating system.
  • Docker is OS level Virtualization.

All containers are started based on Docker image. To find existing images at https://hub.docker.com/

Docker commands line reference

To use command find an image

$ docker search <name>

To run a container based on a Docker Image. The default, to rune command in the foreground. To rune in the background with option -d. Docker to rune latest version available.

$ docker run <options> <image_name>

Find out running containers

$ docker ps

More details running a container

$ docker inspect <name-container>|<container-id>

Providing logs details running a container

$ docker logs <name-container>|<container-id>

To access a container with <host-port>:<containers-port>

$ docker run -d --name <name-container> -p <host-port>:<containers-port> <Image>

Persisting Data for containers

$ docker run -d --name <name-container> -v <host-dir>:<container-dir> <Image>

accessing to a bash shell inside of a container

$ docker run -it <name-container> bash

List all the images on the host

$ docker images

To use docker build command to build the image

$ docker build -t <name> .

Docker Ignoring Files during Build, to exclude sensitive files during build the image.

$ echo file_name.txt >> .dockerignore

To create Data Container

$ docker create -v /config --name dataContainers busybox

Copy files to data containers

$ docker cp config.conf dataContainers:/config/

Mount Volumes From data containers

$ docker run --volumes-from dataContainers ubuntu ls /config

To Export / Import for data Containers

 $ docker export dataContainer > dataContainer.tar
 $ docker import dataContainer.tar

Docker communicating between containers

$ docker run --link <container-name|id>:<alias> New_container

How to get quick stats on Docker containers

$ docker stats

Conclusion

Through the article, you can use the Docker commands line reference as above. I hope will this your helpful. Thank you for reading the DevopsRoles page!

Install docker and learn containers on Centos

Introduction

How to install and configure Docker on centos. Learning to download a Docker image, running a Docker container, and so forth.

Introduce the concept of Docker and containers. Explain their benefits, such as portability, scalability, and isolation. Briefly mention that the blog post will guide readers through the process of installing Docker on CentOS and getting acquainted with containers.

To install Docker and learn about containers on CentOS, Step by step install Docker on Centos 6 and Centos 7. You can follow the steps below

Install docker

Docker is incorporated into Centos 7 extras repositories, due to installation being simple. For Centos 6, you install epel-release” repositories

To install docker on Centos 7

# yum update -y && yum install epel-release -y && yum install docker -y

To install docker on Centos 6

# yum update -y && yum install epel-release -y && yum install docker-io -y

The finish installed docker, To check the status, start, and enable services docker the below commands:

For Centos 7

# systemctl start docker
# systemctl status docker
# systemctl enable docker

For Centos 6

# service docker start
# service docker status
# chkconfig docker on

To Learn basic containers, Docker

To search for a Docker image, for example, a Centos image

# docker search centos

You choose the image and download it locally, Use the docker pull command

# docker pull centos

List all the available Docker images on your host

# docker images

To delete images

# docker rmi centos

Creating and rune a container

# docker run --name My_OS centos cat /etc/hosts

Starting, stats, and stopping a container

# docker start My_OS
# docker stats My_OS
# docker stop My_OS

To Run an Interactive Session in a container

# docker run --name My_OS -it centos bash

To reconnect to the running container you need the container ID or name

# docker attach My_OS

Stopping a running container from the host

# docker kill My_OS

Conclusion

You’ve successfully installed Docker and started learning about containers on CentOS. Additionally, you may find it helpful to explore container orchestration tools like Docker Compose and Kubernetes to manage and deploy multi-container applications. I hope this helps you. Thank you for reading the DevopsRoles page!