Showing posts with label Docker-engine. Show all posts
Showing posts with label Docker-engine. Show all posts

Wednesday, August 3, 2022

#Install #docker on #Centos7, #Centos9, #Ubuntu20

Tested OSs: Centos7, Centos9 and Ubuntu 20


Step-1 (Optional)

*Note: Ignore this step, if you are not in installing docker in the University of Tartu's private cloud

- Create the daemon file manually. This is because of some conflict in University's Openstack Environment.

sudo mkdir -p /etc/docker && cd /etc/docker

- Create and update docker daemon file

1
2
3
4
5
6
sudo tee /etc/docker/daemon.json <<EOF
{
	
"default-address-pools": [{"base":"172.80.0.0/16","size":24}]
}
EOF

Step-2

  • Now run this command. It will add the official Docker repository, download the latest version of Docker, and install it:
curl -fsSL https://get.docker.com/ | sh
  • After installation has completed, start the Docker daemon:
sudo systemctl start docker
  • Verify that it’s running:
sudo systemctl status docker
  • Enable docker

    sudo systemctl enable docker

Step-3

To run docker commands with non-root privileges

  • Create a docker group (If it's already created then ignore): sudo groupadd docker
  • Add a user to docker group: sudo usermod -aG docker $USER
  • Activate the changes: newgrp docker
  • Check the installation by displaying docker version: docker --version

 

 

 - That's all for now.

Monday, June 20, 2022

Installing #neo4j on #centos 9 using #docker and accessing from #remote...

In this post, you will see how to install neo4j graphDB on a remote with no GUI access. We will install this db on centos9 OS and access the web-based GUI on local machine.

Steps:

  • Login to the remote VM using ssh -i <keyfile> centos@<ip of the VM> command
  • Create following directories
    • mkdir neo4j && cd neo4j
    • mkdir -p data logs import plugins
  • Execute following docker command to download and run neo4j docker image
 docker run \
    -d
    --restart always \
    --publish=7474:7474 --publish=7687:7687 \
    --env NEO4J_AUTH=neo4j/test \
    --user="$(id -u):$(id -g)" \
    --volume=$HOME/neo4j/data:/data \
    -v $HOME/neo4j/logs:/logs \
    -v $HOME/neo4j/import:/var/lib/neo4j/import \
    -v $HOME/neo4j/plugins:/plugins \
    neo4j:latest
  • Now in the local machine, open your terminal or command prompt and execute the following command
      ssh -i <keyfile> -N -f -L localhost:7474:localhost:7474 centos@<Remote VM ip>
  • Now open any web browser and enter following address
    • http://localhost:7474
 In the below video, you can get the detailed steps for more better clarity. Please reach out to me https://kodu.ut.ee/~dehury/ if you have any confusion.

Monday, September 20, 2021

Managing Kubernetes clusters using Rancher [20Sept2021]


 
Here is the Environment for me. You may go with single worker node 

Created Tuesday 07 September 2021

Rancher node: Centos 7 (better to keep this separate from cluster nodes), flavor: m3.xsmall
Master Node: Centos 7, m3.xsmall
Worker Node-1: Centos 7, m3.xsmall
Worker Node-2: Centos 7, m3.xsmall

Both Master and Work Node have allow-all security group attached
Minimal ports required are 80/TCP, 443/TCP

[src: https://rancher.com/docs/rancher/v2.x/en/quick-start-guide/deployment/quickstart-manual-setup/

Common installation

  1. Install Docker

  • Create the daemon file manually. This is also because of some conflict in University's Openstack Environment.

        sudo mkdir -p /etc/docker
        sudo tee /etc/docker/daemon.json <<EOF
	{
	  "exec-opts": ["native.cgroupdriver=systemd"],
	  "log-driver": "json-file",
	  "log-opts": {
	    "max-size": "100m"
	  },
	  "storage-driver": "overlay2",
	  "storage-opts": [
	    "overlay2.override_kernel_check=true"
	  ],

"default-address-pools": [{"base":"172.80.0.0/16","size":24}]

	}
	EOF

  • Now run this command. It will add the official Docker repository, download the latest version of Docker, and install it:
curl -fsSL https://get.docker.com/ | sh
  • After installation has completed, start the Docker daemon:
sudo systemctl start docker
ERROR if docker is unable to start, try to check the /etc/docker/daemon.json file
  • Verify that it’s running:
sudo systemctl status docker
  • enable docker to start on boot:
sudo systemctl enable docker
  • To run docker commands with non-root privileges

sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker

Rancher node

  1. Enter the following command to run rancher container
sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 --privileged rancher/rancher
  1. Go to the web browser and hit https://<SERVER_IP_Rancher_Node>
  2. Follow the wizard for initial setup
Once it is done, you should be able to see the dashboard with local as the cluster name

Create a new cluster

src: https://rancher.com/docs/rancher/v2.5/en/quick-start-guide/deployment/quickstart-manual-setup/

  1. Go to the browser and access Rancher Dashboard
  2. From the dashboard, click on Create
  3. Click on Custom
  4. Give Cluster Name as cluster-1 and skipp other infos
  5. Click on Next
  6. Select etcd , Control Plane , Worker
  7. Select the Registration command
    1. The registration command should look like:
sudo docker run -d --privileged --restart=unless-stopped --net=host -v /etc/kubernetes:/etc/kubernetes -v /var/run:/var/run rancher/rancher-agent:v2.6.0 --server https://172.17.90.86 --token bflxwjlsvsrtbnvp8nj5xq82xx2sr5npjsxm82mbtdcfkc9g65x5d8 --ca-checksum f9bc8c23fff67155023fde69026ec83a77f632657f1049fd6ca9ae5732cf59d3 --etcd --controlplane --worker
  1. Go to master node terminal and execute the registration command

At this point you need to wait for few minutes...

  1. After this, you will see in the browser that 1 New node has registered.
  2. Now click on Done
  3. Repeat Step 6 to get the registration command for worker node. For worker node you just need to select Worker

Deleting a node

[src: https://rancher.com/docs/rancher/v2.5/en/cluster-admin/cleaning-cluster-nodes/]
Deleting Docker Containers, Images, and Volumes

Based on what role you assigned to the node, there are Kubernetes components in containers, containers belonging to overlay networking, DNS, ingress controller and Rancher agent. (and pods you created that have been scheduled to this node)

To clean all Docker containers, images and volumes:

docker rm -f $(docker ps -qa)
docker rmi -f $(docker images -q)
docker volume rm $(docker volume ls -q)

Clean the related directories

sudo rm -rf /etc/ceph \
	   /etc/cni \
	   /etc/kubernetes \
	   /opt/cni \
	   /opt/rke \
	   /run/secrets/kubernetes.io \
	   /run/calico \
	   /run/flannel \
	   /var/lib/calico \
	   /var/lib/etcd \
	   /var/lib/cni \
	   /var/lib/kubelet \
	   /var/lib/rancher/rke/log \
	   /var/log/containers \
	   /var/log/kube-audit \
	   /var/log/pods \
	   /var/run/calico

It is now good to reboot the VM with following command:

sudo reboot



-That's all

Monday, October 31, 2016

Installing and running the docker daemon remotely.

Step-1: Installing the Docker
         sudo apt-get install docker.io
After installing, docker will start running automatically.
Step -2: Stoping the docker
         sudo service docker stop

Step-3: configuring the docker
  
sudo docker -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock -d &
This will make the docker daemon to listen through unix socket and the TCP port


Now access the docker daemon 
example-1
  docker -H=tcp://120.126.17.39:2375 run ubuntu


example-2
   docker run ubuntu

example-3
  docker -H=tcp://120.126.17.39:2375 ps -a


example-4
    docker ps -a


For uninstalling use following command
  sudo apt-get purge --auto-remove docker.io
 



When docker-engine is install, I found the command is slightly different from the previous one.
To install docker-engine:  [src]
        sudo apt-get install docker-engine
Stop the docker:
        sudo service docker stop
Following command will enable the docker to listen using both Linux socket and tcp:
          sudo dockerd -H unix:///var/run/docker.sock H tcp://0.0.0.0:2375
Now to access docker daemon:
          sudo docker -H tcp://0.0.0.0:2375 
                 or 
          sudo docker -H tcp://120.126.16.34:2375

tcp://120.126.16.34:2375 is the IP of the daemon host. The IP of daemon host can be different based on your configuration.

Friday, October 21, 2016

Uninstalling Docker-engine from Ubuntu 14.04

Completely Uninstalling Docker-engine including Configuration data and other dependencies

        sudo apt-get purge --auto-remove docker-engine

Uninstalling Docker and its dependencies

        sudo apt-get remove --auto-remove docker-engine

Uninstalling Docker and its configuration data

        sudo apt-get purge docker-engine

Uninstalling only Docker

        sudo apt-get remove docker-engine