Docker container exited instantly with code (127) - docker

In the log file I have this error:
./worker: error while loading shared libraries: libcares.so.2: cannot open shared object file: No such file or directory
I tried everything with the library it exists and its linked to the path.
My Dockerfile :
FROM ubuntu:20.04
RUN apt update -y && apt install libssl-dev -y
WORKDIR /worker
COPY build/worker ./
COPY build/lib /usr/lib
EXPOSE 50051
CMD ./worker
My makefile:
all: clean build
build:
mkdir -p build/lib && \
cd build && cmake .. && make
clean:
rm -rf build
clean-containers :
docker container stop `docker container ls -aq`
docker container rm `docker container ls -a -q`
create-workers :
docker run --name worker1 -p 2001:50051 -d workerimage
docker run --name worker2 -p 2002:50051 -d workerimage
docker run --name worker3 -p 2003:50051 -d workerimage
docker run --name worker4 -p 2004:50051 -d workerimage
docker run --name worker5 -p 2005:50051 -d workerimage
docker run --name worker6 -p 2006:50051 -d workerimage
docker run --name worker7 -p 2007:50051 -d workerimage
docker run --name worker8 -p 2008:50051 -d workerimage
docker run --name worker9 -p 2009:50051 -d workerimage
docker run --name worker10 -p 2010:50051 -d workerimage

make sure libcares.so.2 and other shared libraries are present inside /usr/lib of the container.

Related

GCC builds under teamcity docker agent

I'm trying out teamcity to build GCC binaries with docker agents on centos. I setup a docker agent to connect to builder2 TC server.
$ docker pull jetbrains/teamcity-agent
$ mkdir -p /mnt/builders/teamcity/agent1/conf
$ mkdir -p /mnt/builders/teamcity/agent/work
$ mkdir -p /mnt/builders/teamcity/agent/system
docker run -it --name agent1 \
-e SERVER_URL="http://builder2:8111" \
-e AGENT_NAME="builder2_agent1" \
--hostname builder2_agent \
--dns="xx.xxx.xx.xx" \
-v /mnt/builders/teamcity/agent1/conf:/data/teamcity_agent/conf \
-v /mnt/builders/teamcity/agent/work:/opt/buildagent/work \
-v /mnt/builders/teamcity/agent/system:/opt/buildagent/system \
--network='BuilderNetwork' \
jetbrains/teamcity-agent
All that works good but in order to make a build you must import the devtoolset like this
scl enable devtoolset-10 "/bin/bash"
$ which make
/opt/rh/devtoolset-10/root/usr/bin/make
So how is this done with docker agent? Are these tools to be built in the image or do you expose the /opt/rh dir to the container? Also if you were to expose the volume then how do you install /usr/bin/scl (i.e rh package scl-utils-20130529-19.el7.x86_64) into the docker container? Does it even make sense to run an agent in docker for this?

what is docker run -w flag?

Came across a docker run command that uses -w flag.
docker run -v $(pwd):/project \
-w /project \
-p 8081:8081 \
gcr.io/base-project/myoh:v1
Any idea what the -w flag is for?
Just run docker run --help in your shell.
-w, --workdir string Working directory inside the container
https://docs.docker.com/engine/reference/run/#workdir

Running firefox in a ubuntu docker container on localhost: Unable to init server: Broadway display type not supported:

I am experimenting with running X11 GUI programs from a docker container on localhost:
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y firefox
ARG home=/root
WORKDIR $home
COPY entrypoint.sh .
ENTRYPOINT ["./entrypoint.sh"]
where the entrypont.sh file is:
#! /bin/bash
firefox &
exec bash
Building the image with:
docker build -t firefox-ubuntu-2004 .
And running the container (localhost: Ubuntu 20.04):
XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
DISPLAY="localhost:0"
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
docker run -it --rm \
-e DISPLAY=$DISPLAY \
-v $XAUTH:$XAUTH \
-v $XSOCK:$XSOCK \
-e XAUTHORITY=$XAUTH \
firefox-ubuntu-2004
The output error message from running the last command is:
Unable to init server: Broadway display type not supported: localhost:0
Error: cannot open display: localhost:0
The --net=host in the docker command should do the job
docker run --name myContainer -it --net=host fromMyimage:latest
along with using host.docker.internal instead of localhost for connecting to the docker's host on OSX.

expose port inside docker at docker run

I just want to expose port 5555 which is bind to celery flower, to host ip and the port.Could someone please help on this?
Below is some part of dockerfile.
Make port 80 available to the world outside this container
EXPOSE 5555
Define environment variable
ENV NAME worker-app
create paths
RUN /etc/init.d/celeryd create-paths
clear symfony app cache
RUN cd /srv/clickhq/ && rm -rf var/cache/*
RUN chown -R lighthouse:lighthouse /srv/clickhq/
clear php app cache
USER lighthouse
RUN cd /srv/clickhq/ && ./clearcache.sh
Start celeryd, celerybeat and php-fpm services when the container launches
Blockquote
USER root
RUN chown -R lighthouse:lighthouse /var/run/celery/ && chown -R lighthouse:lighthouse /var/log/celery/
RUN chmod -R 755 /var/log/celery/ && chmod -R 755 /var/run/celery/
RUN chown -R lighthouse:lighthouse /srv/clickhq/
ENTRYPOINT sudo service celeryd start && sudo service celerybeat start && service php7.0-fpm start && service rsyslog start && /usr/bin/python /usr/local/bin/flower -A celery --broker=redis://password#192.168.51.4:6379/0 && bash
Blockquote
Docker run command Im using is
"sudo docker run -it --rm --name worker-app -d worker-app --privileged -p 192.168.51.3:5555:5555 --net="bridge"
The problem is that you are really not passing the argument -p 80:5555 to docker run, but to the entrypoint.
In this command sudo docker run -it --rm --name worker-app -d worker-app --privileged -p 192.168.51.3:5555:5555 --net="bridge", worker-app is the image name, so everything after it (--privileged -p 192.168.51.3:5555:5555 --net="bridge") is a parameter for the entrypoint.
It should work if you change the image name to the end:
sudo docker run -it --rm --name worker-app -d --privileged -p 80:5555 --net="bridge worker-app

SOnarqube using docker and how to run it?

i need to install SonarQube using my docker.
i tried this below code to install
`FROM ubuntu:14.04
RUN apt-get update
RUN apt-get -y install unzip curl openjdk-7-jre-headless
RUN cd /tmp && curl -L -O
https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-7.0.zip
RUN unzip /tmp/sonarqube-7.0.zip
EXPOSE 9000
CMD ["chmod +x","/tmp/sonarqube-7.0/bin/linux-x86-64/sonar.sh"]
CMD ["/sonarqube-7.0/bin/linux-x86-64/sonar.sh","start"]`
its build is successful.
MY QUESTION IS:
1.how can i run it on server?
I tried "docker run -d --name image -p 9000:9000 -p 9092:9092 sonarqube"
but its not connecting..can anyone help me from here or do i need to change in script??
Try below steps.
Modify the Dockerfile last line to:
RUN echo "/sonarqube-7.0/bin/linux-x86-64/sonar.sh start" >> .bashrc
Rebuild the image
Start a container:
docker run -d --name image -p 9000:9000 -p 9092:9092 sonarqube /bin/bash

Resources