Installing and using docker CentOS7

We will not cover what docker does and how it works. We assume you already familiar with basic concepts. We will look into basics of installing and operating docker on CentOS 7. We will be looking into CE )(Community Edition)


We will go over install using repositories

yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo
yum install docker-ce
systemctl start docker

Test docker version

docker --version
docker info
docker run hello-world
docker image ls
docker container ls
docker container ls --all
docker container ls -aq

Example running bash program with docker

mkdir myproject && cd myproject

Edit Dockerfile with following content

FROM bash:4.4
CMD ["bash", "/"]

Create file

echo "IT WORKS"

Build app

docker build -t myapp .
docker image ls

And finally run it

docker run myapp