Dockers
Why dockers?Docker provides environment to run applications in a container, which allow to isolate any OS dependencies or library dependencies.
Some useful links:
https://docs.docker.com/get-started/
https://linuxize.com/post/how-to-install-and-use-docker-on-centos-7/
Installation instructions For Centos:
## Un-install older docker versions.
sudo yum remove docker \
> docker-client \
> docker-client-latest \
> docker-common \
> docker-latest \
> docker-latest-logrotate \
> docker-logrotate \
> docker-engine
##Install these tool/libs before installing docker.
yum install -y yum-utils \ device-mapper-persistent-data \ lvm2
## Setup repository
yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
## install docker CE ##
For latest docker
yum install docker-ce docker-ce-cli containerd.io
For particular version
yum install docker-ce-18.06.3.ce-3.el7 docker-ce-cli-18.06.3.ce-3.el7
start docker daemon boot:
sudo systemctl start dockersudo systemctl enable docker
Check status
sudo systemctl status dockerTest your installation
docker run hello-world
Example pulling official CentOS environment:
1. Create a directory for exmapl
"mkdir docker_test"
2. go to docker_test and create "Dockerfile"
This will have instructions on what to do like , ADD, RUN , COPY etc.
---
RUN rm -rf /etc/yum.repos.d/*.repo
COPY pkey-c /home/2.03-16/data/pkey-c
RUN useradd -ms /bin/bash hsm
ADD https://github.com/krallin/tini/releases/download/v0.18.0/tini-static /tini
RUN chmod +x /tini
ADD bin /bin
ADD lib /lib
ADD opt /opt
ADD etc /etc
---
3. Now build "docker build ."
4. Now run the installation
docker image ls
[root@localhost composetest]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
friendlyhello latest 97ce9a216075 10 minutes ago 84.5MB
python 3.4-alpine c06adcf62f6e 7 weeks ago 72.9MB
hello-world latest fce289e99eb9 4 months ago 1.84kB
5. Now start running the image
docker run -it 9f38484d220f /bin/bash
6. To connect multiple cli sessions
docker exec -it ba02d5d832aa /bin/bash
7. To see which docker processes running
docker ps
8. Docker logs
docker logs| more
docker exec -it ba02d5d832aa /bin/bash
7. To see which docker processes running
docker ps
8. Docker logs
docker logs
EX:
docker logs 9e3284f1a9d0 | more
9. Docker stop : "docker stop "
10. Docker image remove
## This wil remove images whihc are dangling ##
docker rmi $(sudo docker images --filter "dangling=true" -q --no-trunc)
## find the dependent images and remove . below goofy_easley was using centos##
docker rm goofy_easley docker rmi 9f38484d220f
10. Docker image remove
## This wil remove images whihc are dangling ##
docker rmi $(sudo docker images --filter "dangling=true" -q --no-trunc)
## find the dependent images and remove . below goofy_easley was using centos##
docker rm goofy_easley docker rmi 9f38484d220f
11. Copying files to running docker.
docker cp ../LiquidSecurity-NFBE-2.03-15.03.tgz ba02d5d832aa:/root/
12. How do you rebuild docker?
13. How to start a process on docker start?
13. How to start a process on docker start?
14. Are docker images filling up your disk space. Following command will clean it up.
"docker system prune -a --volumes"
15. Running Docker in non root mode.
- $sudo groupadd dokcer
- $sudo usermod -AG docker
- Now logout and login
- run "docker run hello-wrold"
No comments:
Post a Comment