Docker Debian nc command not found - docker

When I build my Debian image from docker-compose, with the command $ docker-compose -f docker-compose-dev.yml build web, like so:
docker-compose-fev.yml
services:
web:
build:
context: ./services/web
dockerfile: Dockerfile-dev
volumes:
- './services/web:/usr/src/app'
ports:
- 5001:5000
environment:
- FLASK_ENV=development
- APP_SETTINGS=project.config.DevelopmentConfig
- DATABASE_URL=postgres://postgres:postgres#web-db:5432/web_dev
- DATABASE_TEST_URL=postgres://postgres:postgres#web-db:5432/web_test
- SECRET_KEY=my_precious
depends_on:
- web-db
- redis
As though it appears to build all packages successfully, I'm getting:
web_1| /usr/src/app/entrypoint.sh: 5: /usr/src/app/entrypoint.sh: nc: not found
If I change #!/bin/sh to #!/bin/bash, error log changes:
web_1| /usr/src/app/entrypoint.sh: line 5: nc: command not found
Dockerfile:
FROM python:3.7-slim-buster
RUN apt-get update && apt-get -y dist-upgrade
RUN apt-get -y install build-essential libssl-dev libffi-dev libblas3 libc6 liblapack3 gcc python3-dev python3-pip cython3
RUN apt-get -y install python3-numpy python3-scipy
# set working directory
WORKDIR /usr/src/app
COPY ./requirements.txt /usr/src/app/requirements.txt
RUN pip3 install -r requirements.txt
# add entrypoint.sh
COPY ./entrypoint.sh /usr/src/app/entrypoint.sh
RUN chmod +x /usr/src/app/entrypoint.sh
# add app
COPY . /usr/src/app
# run server
CMD ["/usr/src/app/entrypoint.sh"]
entrypoint.sh
#!/bin/sh
echo "Waiting for postgres..."
while ! nc -z web-db 5432; do
sleep 0.1
done
rm -rf celery_logs/*
echo "PostgreSQL started"
python manage.py run -h 0.0.0.0
Note: this entrypoint configuration used to work with Alpine, and now has changed to Debian.
what am I missing?

Update the Dockerfile and append,
RUN apt install -y netcat
It should be like,
FROM python:3.7-slim-buster
RUN apt-get update && apt-get -y dist-upgrade
RUN apt-get -y install build-essential libssl-dev libffi-dev libblas3 libc6 liblapack3 gcc python3-dev python3-pip cython3
RUN apt-get -y install python3-numpy python3-scipy
RUN apt install -y netcat

Related

Overriding wagtail modeladmin templates in docker with windows and ubuntu

I'm follow this article to override modeladmin template:
templates/modeladmin/app-name/model-name/
Overriding templates
It was overridded in windows 11 with docker, but not work in ubuntu.
I have no idea why have to use volumes to override modeladmin template and it was only work in windows?
It is also work in windows not use docker.
dockerfile
FROM python:3.8.1-slim-buster
RUN useradd wagtail
EXPOSE 8088
ENV PYTHONUNBUFFERED=1 \
PORT=8088
RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-recommends \
build-essential \
libpq-dev \
libmariadbclient-dev \
libjpeg62-turbo-dev \
zlib1g-dev \
libwebp-dev \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --upgrade pip
RUN pip install "gunicorn==20.0.4"
COPY requirements.txt /
RUN pip install -r /requirements.txt
WORKDIR /app
RUN chown wagtail:wagtail /app
COPY --chown=wagtail:wagtail . /app
USER wagtail
RUN python manage.py collectstatic --noinput --clear --no-post-process
docker-compose.yml
version: '3.8'
services:
web:
build: .
command: gunicorn web.wsgi:application --bind 0.0.0.0:8088
volumes:
- ./project/templates:/app/project/templates
ports:
- '8088:8088'
Can you give me some pointers about how to override it in ubuntu? thanks.

Docker runs on WIndows and only on one of two Linux systems

I have a docker image that I have built that runs on my windows laptop as expected. When I copy and load it on to one of my two Linux systems I get this error when I run docker logs:
Error: 'docker/semantic_search_django/gunicorn.conf' doesn't exist
When I inspect the running container on Windows I can see that "missing" file! Furthermore, if I copy and load the same docker image to my second Linux system, it runs as expected.
This issue just happened today. I've been having success on all 3 systems for the past couple of months until today. Any suggestions would be greatly appreciated. Both Linux systems are running Ubuntu 18.04.5 LTS.
I've tried renamed the images, I've stopped and started the docker daemon, I've even restarted both Linux boxes.
Here are the commands I have used:
docker pull my.artifactory.com/ciee_ssrdjango
docker-compose up -d
My docker-compose.yml
version: "3.8"
services:
web:
image: m.artifactory.com/ciee_ssrdjango
env_file:
- proxy.env
- django.env
container_name: ciee_ssrdjango
volumes:
- query-results-volume:/code
expose:
- "${SSRDJANGO_PORT}"
extra_hosts:
dbhost: ${POSTGRES_DOCKER_IP}
depends_on:
- db
networks:
- ssr_network
networks:
ssr_network:
external: true
volumes:
postgresql-volume:
external: true
query-results-volume:
external: true
My Dockerfile:
FROM ubuntu:18.04
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
COPY ./requirements.txt /requirements.txt
#prevents being asked to set TZ
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update -y && \
apt -y upgrade && \
apt install -y python3-pip && \
apt install -y build-essential libssl-dev libffi-dev libpq-dev python3-dev && \
apt install -y software-properties-common python3.8
RUN python3 -m pip install --upgrade pip setuptools wheel
ENV TZ=US/Eastern
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt update -y & apt install gcc libxml2-dev libxslt-dev postgresql postgresql-contrib postgresql-plpython-10 --no-install-recommends unixodbc-dev unixodbc libpq-dev -y
RUN mkdir /code # && mkdir /code/ciee
RUN pip install nltk
RUN export PATH=~/.local/bin:$PATH
RUN pip install -r /requirements.txt
COPY . /code/
WORKDIR /code
RUN useradd -m user && chmod 777 /home/user && mkdir /code/query_results && chmod 777 /code/query_results
USER user
CMD ["gunicorn", "semantic_search_django.wsgi:application", "--config", "docker/semantic_search_django/gunicorn.conf", "--keep-alive", "600"]
Here's the thing, I've been using these files and commands successfully for many weeks.
I can make one assumption. You are mounting query-results-volume into /code directory in container and your conf file is located inside it. The volume persists between containers – that's the nature of the volumes. So, somehow, the file in question (or even the folder) has been removed from the volume on the problem machine and now container can not get it.

Speed up image building docker with docker compose

i am a newby in docker and I need an installation based on ubuntu of logstash.
I try the official logstash image and without success I can't run it so I decided to build my own installation based on my needs.
It works well but takes a lot of time to build it.
I wonder how can I improve (speed up) my building
This is my Dockerfile
FROM ubuntu:18.04
# RUN adduser --disabled-password --gecos "" ubuntu
# RUN usermod -aG sudo ubuntu
# RUN echo "ubuntu ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
RUN apt-get update && \
apt-get autoclean && \
apt-get autoremove
RUN echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | tee -a /etc/apt/sources.list.d/elastic-7.x.list
RUN apt-get install curl ca-certificates apt-utils wget apt-transport-https default-jre gnupg apt-transport-https software-properties-common -y
# RUN update-alternatives --config java
ENV LANG C.UTF-8
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64
ENV PATH $JAVA_HOME/bin:$PATH
RUN wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -
RUN apt update
RUN apt install ruby-full -y
RUN ruby --version
RUN apt install jruby -y
#install jruby (last version)
RUN jruby --version
RUN apt install logstash
#install plugins and bundles.
RUN cd /usr/share/logstash && gem install bundler
COPY logstash-pcap-test.conf /usr/share/logstash/
RUN mkdir /home/logstash/ && mkdir /home/logstash/traffic
COPY /traffic-example/* /home/logstash/traffic/
WORKDIR /usr/share/logstash
CMD ["/bin/bash","-c","bin/logstash -f logstash-pcap-test.conf --config.reload.automatic"]
And this is my docker-compose
version: "3"
services:
logstash_test:
build:
context: .
dockerfile: container/Dockerfile
image: logstash_test:latest
container_name: logstash_test
hostname: logstash_test
ports:
- 9600:9600
- 8089:8089
networks:
- elknetwork
networks:
elknetwork:
driver: bridge
Any thoughts?

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.

Rclone installation in docker on heroku with telegram bot [Help]

I want to install rclone on a docker image in heroku to able to use Rclone with python telegram bot
I made a heroku.yml file
build:
docker:
worker: Dockerfile
run:
worker: bash start.sh
And start.sh as
python3 -m bot
And Dockerfile as
FROM ubuntu:18.04
WORKDIR /usr/src/app
RUN docker pull rclone/rclone:latest
RUN docker run rclone/rclone:latest version
RUN chmod 777 /usr/src/app
RUN apt -qq update
RUN apt -qq install -y python3 python3-pip locales
COPY requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt
COPY . .
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
CMD ["bash","start.sh"]
I get error The command '/bin/sh -c docker pull rclone/rclone:latest' returned a non-zero code: 127 in the git bash CLI
What Am I doing wrong? Or what is the procedure?
Thanks in advance!
FROM ubuntu:16.04
WORKDIR /app
# line number 12 - 15 in your Dockerfile
RUN echo "LC_ALL=en_US.UTF-8" >> /etc/environment
RUN echo "LANG=en_US.UTF-8" >> /etc/environment
RUN more "/etc/environment"
RUN apt-get update
#RUN apt-get upgrade -y
#RUN apt-get dist-upgrade -y
RUN apt-get install curl htop git zip nano ncdu build-essential chrpath libssl-dev libxft-dev pkg-config glib2.0-dev libexpat1-dev gobject-introspection python-gi-dev apt-transport-https libgirepository1.0-dev libtiff5-dev libjpeg-turbo8-dev libgsf-1-dev fail2ban nginx -y
# Install Rclone
RUN curl -sL https://rclone.org/install.sh | bash
RUN rclone version
# Cleanup
RUN apt-get update && apt-get upgrade -y && apt-get autoremove -y
Based on this answer
You can try this, also don't try to use docker commands inside a Dockerfile.

Resources