Start elasticsearch,kibana,cerebro with docker

Keywords: Linux Docker yum sudo ElasticSearch

Uninstall older versions of docker

Older versions of docker are called docker or docker-engine.If these are installed, uninstall them and their associated dependencies.

sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

Keep/var/lib/docker/content, including images, containers, volumes, and networks.
Docker Engine - Community Package is now called docker-ce.

Install docker

You can install Docker Engine in different ways as needed.

  • Community: Most users set up and install Docker's repository to facilitate installation and upgrade tasks.This is the recommended method.
  • Some users download the RPM package and install it manually and fully manage the upgrade manually.This is useful in situations such as installing Docker on a gas system that does not have access to the Internet.
  • In a test and development environment, some users choose to install Docker using automated handy scripts.

For this demonstration, we chose the community-recommended method of setting up a repository.

Install dokcer and start validation by setting up the repository

  1. Install the required packages.yum-utils provides the yum-config-manager utility, and the device mapper storage driver requires device-mapper-persistent-data and lvm2.

    `sudo yum install -y yum-utils \
    device-mapper-persistent-data \
    lvm2`

  2. Use the following commands to set up a stable repository.

    `sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/l...`

  3. Install docker-ce Community Edition

    You can install the latest version
    yum install docker-ce docker-ce-cli containerd.io

    You can also install a specific version by viewing the supported version number through a command

    yum list docker-ce --showduplicates | sort -r

    sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io

  4. Start docker

    sudo systemctl start docker

  5. Verify that the Docker Engine-Community is properly installed by running the hello-world image.

    sudo docker run hello-world

    [root@VM_0_11_centos ~]# docker run hello-world
    Unable to find image 'hello-world:latest' locally
    latest: Pulling from library/hello-world
    1b930d010525: Pull complete 
    Digest: sha256:6540fc08ee6e6b7b63468dc3317e3303aae178cb8a45ed3123180328bcc1d20f
    Status: Downloaded newer image for hello-world:latest
    
    Hello from Docker!
    This message shows that your installation appears to be working correctly.
    
    To generate this message, Docker took the following steps:
     1. The Docker client contacted the Docker daemon.
     2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
        (amd64)
     3. The Docker daemon created a new container from that image which runs the
        executable that produces the output you are currently reading.
     4. The Docker daemon streamed that output to the Docker client, which sent it
        to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
```

Install docker-compose

  1. Run this command to download the current stable version of Docker Compose

    sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

  2. Applying executable permissions to binaries

    sudo chmod +x /usr/local/bin/docker-compose

  3. Installation Test

    docker-compose --version

Write docker-compose.yml

version: '2.2'
services:
  cerebro:
    image: lmenezes/cerebro:0.8.3
    container_name: cerebro
    ports:
      - "9000:9000"
    command:
      - -Dhosts.0.host=http://elasticsearch:9200
    networks:
      - es7net
  kibana:
    image: docker.elastic.co/kibana/kibana:7.2.0
    container_name: kibana7
    environment:
      - I18N_LOCALE=zh-CN
      - XPACK_GRAPH_ENABLED=true
      - TIMELION_ENABLED=true
      - XPACK_MONITORING_COLLECTION_ENABLED="true"
    ports:
      - "5601:5601"
    networks:
      - es7net
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.2.0
    container_name: es7_01
    environment:
      - cluster.name=geektime
      - node.name=es7_01
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - discovery.seed_hosts=es7_01
      - cluster.initial_master_nodes=es7_01
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - es7data1:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - es7net

volumes:
  es7data1:
    driver: local

networks:
  es7net:
    driver: bridge

Summary of docker commands

  • start-up

docker-compose up

  • Stop Container

docker-compose down

  • Stop the container and remove the data

docker-compose down -v

  • Some docker commands
docker ps
docker stop Name/ContainerId
docker start Name/ContainerId
  • Delete a single container
-f, –force=false; -l, –link=false Remove the specified link and not the underlying container; -v, –volumes=false Remove the volumes associated to the container
  • Delete all containers

rm docker ps -a -q

  • Stop, start, kill, restart a container
 start Name/ID  
 kill Name/ID  
restart name/ID

appendix

Posted by jokerbla on Sun, 18 Aug 2019 20:19:33 -0700