How to convert a systemctl command to supervisord command - docker

I have found the following Dockerfile
FROM centos
# following http://www.pacb.com/wp-content/uploads/2015/09/SMRT-Analysis-Software-Installation-v2.3.0.pdf
MAINTAINER harekrishna#gmail.com
ENV SMRT_ROOT=/opt/smrtanalysis/
ENV SMRT_USER=smrtanalysis
ENV SMRT_GROUP=smrtanalysis
RUN yum groupinstall -y "Development Tools"
RUN yum install -y redhat-lsb net-tools
RUN groupadd $SMRT_GROUP
RUN adduser \
--gid $SMRT_GROUP \
--home-dir $SMRT_ROOT \
--create-home \
--shell /bin/bash \
$SMRT_USER
USER $SMRT_USER
WORKDIR $SMRT_ROOT
RUN curl -LO -# \
http://files.pacb.com/software/smrtanalysis/2.3.0/smrtanalysis_2.3.0.140936.run
RUN curl -LO -# \
https://s3.amazonaws.com/files.pacb.com/software/smrtanalysis/2.3.0/smrtanalysis-patch_2.3.0.140936.p5.run
RUN bash \
smrtanalysis_2.3.0.140936.run \
-p smrtanalysis-patch_2.3.0.140936.p5.run \
--rootdir $SMRT_ROOT \
--batch \
--ignore-syscheck \
--jmstype NONE
ADD ./run /usr/local/bin
#RUN chmod 755 ./run
EXPOSE 8080
CMD ["/usr/local/bin/run"]
Startup scripts:
$SMRT_ROOT/admin/bin/smrtportald-initd start
$SMRT_ROOT/admin/bin/kodosd start
How is it possible to covnert the two above commands to supervised commands?
Thank you in advance.
Mic

Related

Elastic user password is not working for my docker image

When I am using the elasticsearch official docker image ELASTIC_PASSWORD env variable is working good
docker run -dti -e ELASTIC_PASSWORD=my_own_password -e discovery.type=single-node elasticsearch:7.8.0
But when I build my own customized docker image the ELASTIC_PASSWORD is not working can you please help me on this
Here is my Docker file
FROM ubuntu:18.04
ENV \
REFRESHED_AT=2020-06-20
###############################################################################
# INSTALLATION
###############################################################################
### install prerequisites (cURL, gosu, tzdata, JDK for Logstash)
RUN set -x \
&& apt update -qq \
&& apt install -qqy --no-install-recommends ca-certificates curl gosu tzdata openjdk-11-jdk-headless \
&& apt clean \
&& rm -rf /var/lib/apt/lists/* \
&& gosu nobody true \
&& set +x
### set current package version
ARG ELK_VERSION=7.8.0
### install Elasticsearch
# predefine env vars, as you can't define an env var that references another one in the same block
ENV \
ES_VERSION=${ELK_VERSION} \
ES_HOME=/opt/elasticsearch
ENV \
ES_PACKAGE=elasticsearch-${ES_VERSION}-linux-x86_64.tar.gz \
ES_GID=991 \
ES_UID=991 \
ES_PATH_CONF=/etc/elasticsearch \
ES_PATH_BACKUP=/var/backups \
KIBANA_VERSION=${ELK_VERSION}
RUN DEBIAN_FRONTEND=noninteractive \
&& mkdir ${ES_HOME} \
&& curl -O https://artifacts.elastic.co/downloads/elasticsearch/${ES_PACKAGE} \
&& tar xzf ${ES_PACKAGE} -C ${ES_HOME} --strip-components=1 \
&& rm -f ${ES_PACKAGE} \
&& groupadd -r elasticsearch -g ${ES_GID} \
&& useradd -r -s /usr/sbin/nologin -M -c "Elasticsearch service user" -u ${ES_UID} -g elasticsearch elasticsearch \
&& mkdir -p /var/log/elasticsearch ${ES_PATH_CONF} ${ES_PATH_CONF}/scripts /var/lib/elasticsearch ${ES_PATH_BACKUP}
As I think in order to achieve this functionality (set ELASTIC_PASSWORD from command line and it works) for your own container you need to re-configure Elasticsearch startup script. It's not a trivial task.
For example here is docker-entrypoint.sh from official docker image.
https://github.com/elastic/elasticsearch/blob/master/distribution/docker/src/docker/bin/docker-entrypoint.sh
You can see that script do all 'hidden' work to allow us to run it by only command.

docker run claims a command needs admin access

bash-3.2$ docker run -it -e DISPLAY=$IP:0 -v /tmp/.X11-unix:/tmp/.X11-unix -v `pwd`:`pwd` josh:latest
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
bash: /home/ros/catkin_ws/devel/setup.bash: No such file or directory
And my dockerfile is:
FROM ros:kinetic-robot-xenial
MAINTAINER Joshua Schraven
RUN apt-get update && apt-get install --assume-yes \
vim-nox \
sudo \
python-pip \
ros-kinetic-desktop-full \
ros-kinetic-turtlebot3 \
ros-kinetic-turtlebot3-bringup \
ros-kinetic-turtlebot3-description \
ros-kinetic-turtlebot3-fake \
ros-kinetic-turtlebot3-gazebo \
ros-kinetic-turtlebot3-msgs \
ros-kinetic-turtlebot3-navigation \
ros-kinetic-turtlebot3-simulations \
ros-kinetic-turtlebot3-slam \
ros-kinetic-turtlebot3-teleop
# create non-root user
ENV USERNAME ros
RUN adduser --ingroup sudo --disabled-password --gecos "" --shell /bin/bash --home /home/$USERNAME $USERNAME
RUN bash -c "echo ros:ros | chpasswd"
ENV HOME /home/$USERNAME
USER $USERNAME
# create catkin_ws
RUN mkdir /home/$USERNAME/catkin_ws
WORKDIR /home/$USERNAME/catkin_ws
# add catkin env
RUN echo 'source /opt/ros/kinetic/setup.bash' >> /home/$USERNAME/.bashrc
RUN echo 'source /home/$USERNAME/catkin_ws/devel/setup.bash' >> /home/$USERNAME/.bashrc
I don't know what command is causing the problem, nor how I would trouble shoot that myself.

How to get an X11 socket connection between a docker container and the desktop

I wish to run Pycharm community within Docker on my desktop. I have created a Dockerfile (below) and seen it work fine on Mac.
FROM debian:buster-slim
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
ca-certificates \
curl \
apt-utils \
dirmngr \
gnupg \
libasound2 \
libdbus-glib-1-2 \
libgtk-3-0 \
libxrender1 \
libx11-xcb-dev \
libx11-xcb1 \
libxt6 \
xz-utils \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
ENV HOME /home/user
RUN useradd --create-home --home-dir $HOME user \
&& chown -R user:user $HOME
ENV LANG C.UTF-8
RUN apt-get update && \
apt-get install -y python-pip \
vim \
wget \
x11-utils \
xfonts-base \
xpra
# install PyCharm
RUN cd / && \
wget -q http://download.jetbrains.com/python/pycharm-community-2019.1.1.tar.gz && \
tar xvfz pycharm-community-2019.1.1.tar.gz && \
rm pycharm-community-2019.1.1.tar.gz
USER user
CMD [ "/pycharm-community-2019.1.1/bin/pycharm.sh"]
However when I try to run this on Ubuntu I get X11 errors from the Pycharm code:
Start Failed: Failed to initialize graphics environment
java.awt.AWTError: Can't connect to X11 window server using ':1' as
the value of the DISPLAY variable. at
java.desktop/sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
The command to invoke the container is:
docker run -it --rm -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=${DISPLAY} <<image_id>>
I have tried many variations on the DISPLAY var (eg unix$DISPLAY), but none have worked.
Update:
I ran:
docker run -it --rm -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=${DISPLAY} --entrypoint /bin/sh <<image_id>>
to get access into the container, and then ran:
$ ls -l /tmp
total 0
I am confused - I thought the X11 socket residing in my host machine would have been bound to the same location in the container. Is this a red-herring?

Best way to install ros simulation for turtle bot 3 with docker for debian:buster

What do I have to do to run the Turtlebot 3 Simulation as described in http://emanual.robotis.com/docs/en/platform/turtlebot3/simulation/ on a debian:buster system using docker?
The steps for debian:stretch using repositories in http://wiki.ros.org/lunar/Installation/Debian are not working with debian:buster, see https://github.com/ros-infrastructure/rospkg/issues/125
I finally found a solution to my question.
Create a Dockerfile as follows:
FROM osrf/ros:kinetic-desktop-full-jessie
RUN apt-get update && apt-get install -y --no-install-recommends screen
RUN apt-get install -y --no-install-recommends \
ros-kinetic-joy \
ros-kinetic-teleop-twist-joy \
ros-kinetic-teleop-twist-keyboard \
ros-kinetic-laser-proc \
ros-kinetic-rgbd-launch \
ros-kinetic-depthimage-to-laserscan \
ros-kinetic-rosserial-arduino \
ros-kinetic-rosserial-python \
ros-kinetic-rosserial-server \
ros-kinetic-rosserial-client \
ros-kinetic-rosserial-msgs \
ros-kinetic-amcl \
ros-kinetic-map-server \
ros-kinetic-move-base \
ros-kinetic-urdf \
ros-kinetic-xacro \
ros-kinetic-compressed-image-transport \
ros-kinetic-rqt-image-view \
ros-kinetic-gmapping \
ros-kinetic-navigation
RUN mkdir -p /root/catkin_ws/src/ \
&& cd /root/catkin_ws/src/ \
&& git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git \
&& git clone https://github.com/ROBOTIS-GIT/turtlebot3.git \
&& git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
RUN /bin/bash -c "source /opt/ros/kinetic/setup.bash; cd /root/catkin_ws && /opt/ros/kinetic/bin/catkin_make && /opt/ros/kinetic/bin/catkin_make -DCMAKE_INSTALL_PREFIX=/opt/ros/kinetic install"
RUN apt-get install -y --no-install-recommends vim bash-completion sudo
RUN apt-get install -y --no-install-recommends apt-utils
RUN useradd --create-home --shell /bin/bash robo
RUN echo "robo ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers.d/robo && chmod 0440 /etc/sudoers.d/robo
COPY ./start_simu.sh /usr/local/bin
RUN chmod 755 /usr/local/bin/start_simu.sh
USER robo
WORKDIR /home/robo
RUN rm -rf /var/lib/apt/lists/*
Add a file start_simu.sh in the same directory, containing:
#!/bin/bash
screen -dmS turtlebot_fake /bin/bash -c "source /opt/ros/kinetic/setup.bash;env TURTLEBOT3_MODEL=burger roslaunch turtlebot3_fake turtlebot3_fake.launch"
sleep 2
screen -S turtlebot_fake -X screen /bin/bash -c "source /opt/ros/kinetic/setup.bash;env TURTLEBOT3_MODEL=burger roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch"
source "/opt/ros/$ROS_DISTRO/setup.bash"
exec "/bin/bash"
Now built your docker image using sudo docker build --tag ros:turtlebot3_fake_node .
Run the image:
xhost +local:root
sudo docker run -it --env="DISPLAY" --env="QT_X11_NO_MITSHM=1" --volume="/tmp/.X11-unix:/tmp/.X11-uni
x:rw" ros:turtlebot3_fake_node /usr/local/bin/start_simu.sh
If image is stopped, do xhost -local:root.
The simulation is running in screen, connect to it via screen -R.

Multiple dependent ? Dockerfiles building a LAMP container

I'm trying to build a LAMP container and I have already built several containers: httpd 2.4.23, redis 3.0.7, mysql 5.6.30 by compiling them myself from source code downloaded archives. I have based all of these above on the debian container.
Now that I'm doing the php 5.6.20 container it complains that it does not know about apache and mysql.
Here is the Dockerfile for the php container:
FROM debian
RUN apt-get update
RUN apt-get install -y build-essential;
RUN apt-get install -y cmake;
RUN apt-get install -y libfreetype6-dev libjpeg-dev libpng12-dev libcurl4-openssl-dev libbz2-dev libxml2-dev libxslt-dev libgd2-xpm-dev php5-imap libz-dev
WORKDIR /usr/bin/
COPY php-5.6.20.tar.gz /usr/bin/
RUN gzip -d php-5.6.20.tar.gz
RUN tar -xvf php-5.6.20.tar
RUN ln -s php-5.6.20 php
WORKDIR /usr/bin/php/
RUN ./configure \
--prefix=/usr/bin/ \
--with-apxs2=/usr/bin/apache/bin/apxs \
--with-config-file-path=/usr/bin/php-5.6.20/ \
--enable-libgcc \
--with-mysqli=/usr/bin/mysql/mysql_config \
--with-zlib-dir=/usr \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-gd \
--enable-gd-native-ttf \
--with-freetype-dir=/usr \
--enable-ftp \
--enable-xml \
--enable-zip \
--with-bz2 \
--enable-wddx \
--without-pear \
--enable-mbstring \
--with-curl
RUN make
RUN make install
I wonder if I should base it instead on: FROM httpd:2.4.23. But then I would need to base httpd on the mysql one, and / or on the redis one... I don't really like that setup.
I have also installed Docker Compose but I wonder if it could be helpful in my situation.
UPDATE: Here is the fully working Dockerfile
FROM debian
RUN apt-get update
RUN apt-get install -y build-essential;
RUN apt-get install -y cmake;
RUN apt-get install -y openssl libssl-dev;
RUN apt-get install -y libpcre3 libpcre3-dev
WORKDIR /usr/bin/
COPY httpd-2.4.23.tar.gz /usr/bin/
RUN gzip -d httpd-2.4.23.tar.gz
RUN tar -xvf httpd-2.4.23.tar
RUN ln -s httpd-2.4.23 httpd
COPY apr-1.5.2.tar.gz /usr/bin/httpd/srclib/
COPY apr-util-1.5.4.tar.gz /usr/bin/httpd/srclib/
WORKDIR /usr/bin/httpd/srclib/
RUN gzip -d apr-1.5.2.tar.gz
RUN gzip -d apr-util-1.5.4.tar.gz
RUN tar -xvf apr-1.5.2.tar
RUN tar -xvf apr-util-1.5.4.tar
RUN ln -s apr-1.5.2 apr;
RUN ln -s apr-util-1.5.4 apr-util
WORKDIR /usr/bin/httpd/
RUN ./configure \
--prefix=/usr/bin/apache \
--enable-rewrite \
--enable-deflate \
--enable-ssl
RUN make
RUN make install
RUN apt-get update
RUN apt-get install -y libncurses-dev
COPY mysql-5.6.30.tar.gz /usr/bin/
WORKDIR /usr/bin/
RUN gzip -d mysql-5.6.30.tar.gz
RUN tar -xvf mysql-5.6.30.tar
RUN ln -s mysql-5.6.30 mysql
WORKDIR /usr/bin/mysql/
RUN mkdir install; mkdir install/data; mkdir install/var; mkdir install/etc; mkdir install/tmp
RUN cd /usr/bin/mysql/; cmake \
-DCMAKE_INSTALL_PREFIX=/usr/bin/mysql/install \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/usr/bin/mysql/install/data \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/bin/mysql/install/boost \
-DMYSQL_UNIX_ADDR=/usr/bin/mysql/install/tmp/mysql.sock
RUN make
RUN make install
RUN apt-get update
RUN apt-get install -y libfreetype6-dev libjpeg-dev libpng12-dev libcurl4-openssl-dev libbz2-dev libxml2-dev libxslt-dev libgd2-xpm-dev php5-imap libz-dev
WORKDIR /usr/bin/
COPY php-5.6.20.tar.gz /usr/bin/
RUN gzip -d php-5.6.20.tar.gz
RUN tar -xvf php-5.6.20.tar
RUN ln -s php-5.6.20 php
WORKDIR /usr/bin/php/
RUN ./configure \
--prefix=/usr/bin/php \
--with-apxs2=/usr/bin/apache/bin/apxs \
--with-config-file-path=/usr/bin/php-5.6.20/ \
--enable-libgcc \
--with-mysqli=/usr/bin/mysql/install/bin/mysql_config \
--with-zlib-dir=/usr \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-gd \
--enable-gd-native-ttf \
--with-freetype-dir=/usr \
--enable-ftp \
--enable-xml \
--enable-zip \
--with-bz2 \
--enable-wddx \
--without-pear \
--enable-mbstring \
--with-openssl
--with-curl
RUN make
RUN make install
ENTRYPOINT ["/usr/bin/apache/bin/apachectl", "start", "-D FOREGROUND"]
EXPOSE 80
# Build the container: docker build -t stephaneeybert/httpd:2.4.23 .
# Run the container: docker run -d -p 127.0.0.1:80:80 --name httpd stephaneeybert/httpd:2.4.23
# Check that the port is open: nmap -p 8081 localhost
If you need apache running in your container, you can install apache in your image with above Dockerfile, just as the same as you install the build-essential stuffs. Which means:
RUN apt-get install -y apache2
or similar command. If you also need the configure for this apache application, you can use ADD or COPY command to add your configure file from outside to inside of your container. More details can be found here.
If you need apache as an independent container, you can use docker-compse to achieve it. Start apache in another container, then use depends_on to config the dependency between your containers. You may use ports to change the port number of each container, so they can communicate between each other.

Resources