How to install elasticsearch in a docker container? - docker

I am trying to install elasticsearch in an ubuntu docker container. This is my Dockerfile:
FROM ubuntu:21.04 as elastic_install
RUN apt-get update
RUN apt-get install -y wget gnupg apt-transport-https openjdk-8-jdk
RUN wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -
RUN echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | tee /etc/apt/sources.list.d/elastic-7.x.list
RUN apt-get update && apt-get install -y elasticsearch
When I now try to run elasticsearch, it is killed after a few seconds with the following message:
root#18c3d6649c1b:/# /usr/share/elasticsearch/bin/elasticsearch
Killed
root#18c3d6649c1b:/# /usr/share/elasticsearch/bin/elasticsearch -d
/usr/share/elasticsearch/bin/elasticsearch: line 95: 369 Killed exec "$JAVA" "$XSHARE" $ES_JAVA_OPTS -Des.path.home="$ES_HOME" -Des.path.conf="$ES_PATH_CONF" -Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" -Des.distribution.type="$ES_DISTRIBUTION_TYPE" -Des.bundled_jdk="$ES_BUNDLED_JDK" -cp "$ES_CLASSPATH" org.elasticsearch.bootstrap.Elasticsearch "$#" <<< "$KEYSTORE_PASSWORD"
root#18c3d6649c1b:/#
How do I install/run elasticsearch correctly? Am I missing something crucial?

When directly running elasticsearch, the environment variables ES_PATH_CONFIG and ES_JAVA_OPTS must be defined.
elasticuser#c5f357e42e51:/# ES_PATH_CONF=/etc/elasticsearch ES_JAVA_OPTS="-Xms8g -Xmx8g" /usr/share/elasticsearch/bin/elasticsearch

Related

Port missing in Docker container

I wanted to install apache, php7, postgres12, node, java in ubuntu:18.04 base image dockerfile and wanted to show postgre data in php file. After building and running the container when I checked the process status, the port is missing. I started docker recently so I am new in this. Here is my Dockerfile
FROM ubuntu:18.04
ARG DEBIAN_FRONTEND=noninteractive
# # Install openjdk-8-jdk
RUN apt-get update && \
apt-get install -y openjdk-8-jdk
RUN apt-get -y install nodejs
RUN apt-get update && apt-get -qq -y install curl
RUN apt-get -y install apache2
RUN apt-get -y install php7.2
RUN apt-get -y install libapache2-mod-php7.2
RUN rm -f /var/www/html/index.html
COPY . /var/www/html
RUN apt-get update && apt-get install -y gnupg2 && apt-get install -y wget
Run wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main" > /etc/apt/sources.list.d/pgdg.list
RUN apt-get update && apt-get install -y postgresql-12 postgresql-client-12
USER postgres
RUN /etc/init.d/postgresql start &&\
psql --command "CREATE USER docker WITH SUPERUSER PASSWORD 'docker';" &&\
createdb -O docker docker
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/12/main/pg_hba.conf
RUN echo "listen_addresses='*'" >> /etc/postgresql/12/main/postgresql.conf
EXPOSE 80 5432
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
error
PS G:\Docker\test-docker-ubuntu-php\website> docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1fba1b8327fd test-custom-all "/usr/sbin/apache2ct…" 2 minutes ago Exited (1) 2 minutes ago test-custom
PS G:\Docker\test-docker-ubuntu-php\website> docker logs 1fba1b8327fd
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
Action '-D FOREGROUND' failed.
The Apache error log may have more information.
Can you help me with this?
Thanks

How to write docker-compose file for bbb (big blue button)?

I find a Big Blue Button Dockerfile on [ bigbluebutton /docker ][1] [1]: https://github.com/bigbluebutton/docker
And second week I tryed to write docker-compose.yml file.
How to write docker-compose.yml file. I tried but not success.
This is Dockerfile [ bigbluebutton /docker ][1] [1]: https://github.com/bigbluebutton/docker
FROM ubuntu:16.04
MAINTAINER ffdixon#bigbluebutton.org
ENV DEBIAN_FRONTEND noninteractive
# RUN echo 'Acquire::http::Proxy "http://192.168.0.130:3142";' > /etc/apt/apt.conf.d/01proxy
RUN apt-get update && apt-get install -y wget
RUN echo "deb http://ubuntu.bigbluebutton.org/xenial-200 bigbluebutton-xenial main " | tee /etc/apt/sources.list.d/bigbluebutton.list
RUN wget http://ubuntu.bigbluebutton.org/repo/bigbluebutton.asc -O- | apt-key add -
RUN apt-get update && apt-get -y dist-upgrade
# -- Setup tomcat7 to run under docker
RUN apt-get install -y \
haveged \
net-tools \
supervisor \
sudo \
tomcat7
RUN sed -i 's|securerandom.source=file:/dev/random|securerandom.source=file:/dev/urandom|g' /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/java.security
ADD mod/tomcat7 /etc/init.d/tomcat7
RUN chmod +x /etc/init.d/tomcat7
RUN apt-get install -y language-pack-en
RUN update-locale LANG=en_US.UTF-8
# -- Install BigBlueButton
RUN echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections
RUN apt-get install -y bigbluebutton
RUN apt-get install -y bbb-demo
# -- Install mongodb (for HTML5 client)
RUN sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
RUN echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
RUN sudo apt-get update && sudo apt-get install -y mongodb-org curl
# -- Install nodejs (for HTML5 client)
RUN apt-get install -y apt-transport-https
RUN curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
RUN echo 'deb http://deb.nodesource.com/node_8.x xenial main' > /etc/apt/sources.list.d/nodesource.list
RUN echo 'deb-src http://deb.nodesource.com/node_8.x xenial main' >> /etc/apt/sources.list.d/nodesource.list
RUN apt-get update && apt-get install -y nodejs
# -- Install HTML5 client
RUN apt-get install -y bbb-html5
# -- Install supervisor to run all the BigBlueButton processes (replaces systemd)
RUN apt-get install -y supervisor
RUN mkdir -p /var/log/supervisor
ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# -- Modify FreeSWITCH event_socket.conf.xml to listen to IPV4
ADD mod/event_socket.conf.xml /opt/freeswitch/etc/freeswitch/autoload_configs
# -- Finish startup
ADD setup.sh /root/setup.sh
ENTRYPOINT ["/root/setup.sh"]
CMD []
So this is my docker-compose file. But that file not worked. I lack knowledge and qualification.
version: '3'
services:
bigbluebutton:
build: .
image: bigbluebutton/bigbluebutton
ports:
- "80:80"
expose:
- "1935/tcp"
- "5066/tcp"
- "2202"
Thanks for your answers.
just you need lines below in Docckerfiles becuse bbb need configure and this code passing this step;
`-RUN apt-get install -y bigbluebutton(remove)
+RUN apt-get install -y bigbluebutton || :
+RUN gem install bundler -v 1.16.1
+RUN apt-get install -y bigbluebutton
RUN apt-get install -y bbb-demo`
this is not bug just compile error.
I think you did not indent correctly expose subsection. I would write:
version: '3'
services:
bigbluebutton:
build: .
image: bigbluebutton/bigbluebutton
ports:
- "80:80"
expose:
- "1935/tcp"
- "5066/tcp"
- "2202"
If you use bigbluebutton/bigbluebutton image from DockerHub, you don't need neither build section nor Dockerfile itself.

How to install Docker inside my ubuntu container?

I installed docker inside a container running on ubuntu:18.04 to run my nodejs app, I need docker installed inside this container because i need to dockerize an other small app
Her is my Dockerfile
FROM ubuntu:18.04
WORKDIR /app
COPY package*.json ./
# Install Nodejs
RUN apt-get update
RUN apt-get -y install curl wget dirmngr apt-transport-https lsb-release ca-certificates software-properties-common gnupg-agent
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get -y install nodejs
# Install Chromium
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
RUN apt-get update
RUN apt-get install -y google-chrome-unstable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst \
--no-install-recommends
RUN rm -rf /var/lib/apt/lists/*
# Install Docker
RUN curl -fsSL https:/download.docker.com/linux/ubuntu/gpg | apt-key add -
RUN apt-key fingerprint 0EBFCD88
RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
RUN apt-get update -y
RUN apt-get install -y docker-ce docker-ce-cli containerd.io
RUN npm install
COPY . .
CMD [ "npm", "start" ]
EXPOSE 3000
When the container is up, i docker exec -it app bash.
If i do a service docker start then ps ax, got this
PID TTY STAT TIME COMMAND
115 ? Z 0:00 [dockerd] <defunct>
What can i do to be able to use docker inside the container or is there a docker image not using apk but apt-get ? Because when i need to use it, i got this error :
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
First thing better to use one of the base images, either for node-image and install docker and for docker-image and installed node, instead of creating image from scratch. All you need
FROM node:buster
RUN apt-get update
RUN apt install docker.io -y
RUN docker --version
ENTRYPOINT nohup dockerd >/dev/null 2>&1 & sleep 10 && node /app/app.js
second thing, The error Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?, The reason is you are not starting the docker process in the Dockefile, and also running multiple processes in the container is not recommended, as if Docker process dies you will not know the status, you have to put one process in the background.
CMD nohup dockerd >/dev/null 2>&1 & sleep 10 && node /app/app.js
and run
docker run --privileged -it -p 8000:8000 -v /var/run/docker.sock:/var/run/docker.sock your_image

Not able to access elasticsearch from docker container

elastic search is successfully running on docker container. but i'm not able access in browser. i mapped ports correctly. but the problem is in docker container. in container elasticsearch is mapped with localhost
127.0.0.1:9200
Dokcerfile
FROM ubuntu:16.04
MAINTAINER Rajesh Gurram
RUN apt-get update && \
apt-get install -y net-tools curl wget gnupg
RUN apt-get install -y software-properties-common
RUN add-apt-repository ppa:webupd8team/java && \
apt-get update && \
echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \
apt-get install -y oracle-java8-installer && apt-get clean
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle
RUN apt-get install apt-transport-https
RUN wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add - && \
echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | tee -a /etc/apt/sources.list.d/elastic-6.x.list && \
apt update && apt install -y elasticsearch
RUN sed -i 's/#network.host: 192.168.0.1/network.host: 0.0.0.0/g' /etc/elasticsearch/elasticsearch.yml
EXPOSE 9200 9300
Run Below command on Host machine it will resolve the issue
$ sysctl -w vm.max_map_count=262144
If you want to use docker to get an instance of Elasticsearch, you can read the following Guide:
https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
You can also use docker images directly from elastic, if ubuntu is not a necessary base image:
https://www.docker.elastic.co/
If you want to upgrade to an ELK Stack later on, I recommend a docker volume for persistency purposes.

Yarn not in path on Laradock worskpace when using it in inline docker exec command

I have a problem using Laradock and yarn with an inline docker exec command from "outside" the workspace container.
When I use it from inside the workspace container, everything is working as expected :
docker exec -it --user=laradock laradock_workspace_1 bash
yarn -v
1.3.2
When I try to use it from an inline command, here is what happens :
docker exec -it --user=laradock laradock_workspace_1 yarn -v
OCI runtime exec failed: exec failed: container_linux.go:296: starting container process caused "exec: \"yarn\": executable file not found in $PATH": unknown
Am I doing anything wrong ?
I found the solution myself.
For those who encounter the same issue, just use docker exec following the example below, in order to get access to node or yarn :
docker exec -it --user=laradock laradock_workspace_1 bash --login -c "yarn -v"
I found the solution here : https://gitlab.com/gitlab-org/gitlab-runner/issues/82
try this
#apt-get install sudo -y
#sudo apt-get install apt-transport-https
#sudo apt-get install apt-transport-https
#apt-get remove node
#apt-get remove yarn
#curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
#sudo apt-get install -y nodejs
#curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
#echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
#sudo apt-get update && sudo apt-get install yarn
#apt-get remove node
#apt-get remove yarn
#curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
#sudo apt-get install -y nodejs
#curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
#echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
#sudo apt-get update && sudo apt-get install yarn
#yarn -v
1.13.0
#yarn install

Resources