Docker LAMP stack - lstat apache_default: no such file or directory? - docker

I tried to installed a LAMP stack with a DockerFile in a directory on my desktop /home/username/Desktop/docker/lamp/:
FROM ubuntu:16.04
VOLUME ["/var/www"]
RUN apt-get update && \
apt-get dist-upgrade -y && \
apt-get install -y \
apache2 \
php7.0 \
php7.0-cli \
libapache2-mod-php7.0 \
php7.0-gd \
php7.0-json \
php7.0-ldap \
php7.0-mbstring \
php7.0-mysql \
php7.0-pgsql \
php7.0-sqlite3 \
php7.0-xml \
php7.0-xsl \
php7.0-zip \
php7.0-soap
COPY apache_default /etc/apache2/sites-available/000-default.conf
COPY run /usr/local/bin/run
RUN chmod +x /usr/local/bin/run
RUN a2enmod rewrite
EXPOSE 80
CMD ["/usr/local/bin/run"]
Then on my terminal, I run it:
$ docker build -t docker-lamp .
Step 4 : COPY apache_default /etc/apache2/sites-available/000-default.conf
lstat apache_default: no such file or directory
What I have done wrong? How can I fix this?

First of all, are you 100% sure the files apache_default and run are in the same directory as the Dockerfile?

Related

Docker: COPY failed: stat <file>: file does not exist

I am trying to copy a file into my docker container but the command fails. The file is in the same directory as the Dockerfile, so I don't understand the reason for the error.
I'd appreciate any help or advice. Thanks beforehand.
This is the code:
FROM ubuntu:20.04 as builder
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y \
build-essential \
cmake \
software-properties-common \
libopencv-dev
RUN add-apt-repository -y ppa:chrberger/libcluon
RUN apt-get update
RUN apt-get install -y libcluon
ADD . /opt/sources
WORKDIR /opt/sources
RUN mkdir build && \
cd build && \
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/tmp/dest .. && \
make && make install
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update --fix-missing
RUN apt-get install -y \
libopencv-core4.2 \
libopencv-imgproc4.2 \
libopencv-video4.2 \
libopencv-calib3d4.2 \
libopencv-features2d4.2 \
libopencv-objdetect4.2 \
libopencv-highgui4.2 \
libopencv-videoio4.2 \
libopencv-flann4.2 \
libopencv-dnn-dev \
python3-opencv
WORKDIR /usr/bin
COPY --from=builder /tmp/dest /usr
COPY --from=builder yolov3-tiny_obj.cfg /params
ENTRYPOINT ["/usr/bin/opendlv-perception-helloworld"]
Could you please clarify which line in your Dockerfile causes the error message?
Is the file you are trying to copy from your working directory yolov3-tiny_obj.cfg?
If that is the case, it fails because you specify to copy it from the builder stage.
The line should probably look like this:
COPY yolov3-tiny_obj.cfg /params

Error "failed to solve with frontend dockerfile.v0: failed to build LLB: executor failed running"

I am trying to deploy Shiny App through Docker using windows 10 machine(8GB RAM).
Here is the Dockerfile :
# Base image https://hub.docker.com/u/rocker
FROM rocker/shiny:3.6.3
# system libraries of general use
RUN apt-get update -qq && apt-get -y --no-install-recommends install \
libxml2-dev \
libcairo2-dev \
libsqlite3-dev \
libmariadbd-dev \
libmariadbclient-dev \
libpq-dev \
libssl-dev \
libcurl4-openssl-dev \
libssh2-1-dev \
unixodbc-dev \
&& install2.r --error \
--deps TRUE \
tidyverse \
dplyr \
devtools \
formatR \
remotes \
selectr \
caTools \
BiocManager \
&& rm -rf /tmp/downloaded_packages
# copy necessary files
## app folder
COPY /shinyapp/shinyapp.Rproj /srv/shiny-server/
COPY /shinyapp/ui.R /srv/shiny-server/
COPY /shinyapp/server.R /srv/shiny-server/
COPY /shinyapp/global.R /srv/shiny-server/
# install renv & restore packages
RUN Rscript -e 'install.packages("shiny", repos='http://cran.rstudio.com/')'
RUN Rscript -e 'install.packages("shinydashboard", repos='http://cran.rstudio.com/')'
RUN Rscript -e 'install.packages("glue", repos='http://cran.rstudio.com/')'
# expose port
EXPOSE 3838
RUN sudo chown -R shiny:shiny /srv/shiny-server
# run app on container start
CMD ["/usr/bin/shiny-server.sh"]
The Folder Structure is as follows :
Dockerfile
shinyapp ---> global.R ,
ui.R,
server.R
I tried troubleshooting and checked the name of the files. Everything is correct.
But still getting the error
Any help will be great !!
Follow this steps
/Users/myUserName/.docker
ls -a
rm -rf .token_seed
if it doesn't resolve the issue
remove '.token_seed.lock' file as well

Why Container does not run when I create a VOLUME?

I'm new using dockers and trying to create a volume between Windows directory and Debian Container.
although the dockerfile does not have WORKDIR, I decided use default path inside container, for example, /home/ or /, whatever folder, path.
Is necessary create a WORKDIR to use VOLUME? I think no! what I need to do?
docker run --rm -v %echo%:/home/ --name rust_container rust
dockerfile:
FROM debian:buster-slim
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates \
gcc \
libc6-dev \
wget \
; \
\
url="https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init"; \
wget "$url"; \
chmod +x rustup-init; \
./rustup-init -y --no-modify-path --default-toolchain nightly; \
rm rustup-init; \
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \
rustup --version; \
cargo --version; \
rustc --version; \
\
apt-get remove -y --auto-remove \
wget \
; \
rm -rf /var/lib/apt/lists/*;
You don’t need to set the workdir to use a volume, the workdir will default to the root folder. The directory you reference in the -v argument needs to exist in the container folder structure though because you are mounting a volume. So if /home/ doesn’t exist there is nothing for the volume to mount to. If you include a host point like /foo/bar:/home you will create a bind mount not a volume which mounts the host file system directory inside the container.

Dockerising a shiny app

I am trying to create a docker container for a shiny application. To do that, I have the following docker file:
# Start from an image containing R
FROM r-base:latest
# Install dependencies
RUN apt-get update && apt-get install -y \
sudo \
gdebi-core \
pandoc \
pandoc-citeproc \
libcurl4-gnutls-dev \
libcairo2-dev/unstable \
libxt-dev \
libssl-dev \
gsl-bin \
libgsl0-dev \
default-jdk
RUN wget --no-verbose https://s3.amazonaws.com/rstudio-shiny-server-os-build/ubuntu-12.04/x86_64/VERSION -O "version.txt" && \
VERSION=$(cat version.txt) && \
wget --no-verbose "https://s3.amazonaws.com/rstudio-shiny-server-os-build/ubuntu-12.04/x86_64/shiny-server-$VERSION-amd64.deb" -O ss-latest.deb && \
gdebi -n ss-latest.deb && \
rm -f version.txt ss-latest.deb
# I needed this for rJava-related errors
RUN R CMD javareconf
# Install R packages required by my app
RUN R -e "install.packages(c('shiny', 'xlsx', 'tidyr', 'DT', 'RColorBrewer', 'ggdendro', 'dendsort', 'grid', 'gridExtra', 'igraph', 'circlize', 'gplots', 'shinyFiles', 'shinydashboard', 'shinyjs', 'devtools', 'fpc', 'cluster', 'readr', 'CytobankAPI', 'stringr', 'dplyr', 'tibble'), repos='http://cran.rstudio.com/')"
# Install Bioconductor dependencies
RUN Rscript -e 'source("http://bioconductor.org/biocLite.R")' -e 'biocLite("ComplexHeatmap")'
# Remove Shiny example inherited from the base image
RUN rm -rf /srv/shiny-server/*
# copy the app to the image
COPY shiny-server.conf /etc/shiny-server/shiny-server.conf
RUN mkdir /srv/shiny-server/cytocluster/
COPY ./* /srv/shiny-server/cytocluster/
EXPOSE 3838
COPY shiny-server.sh /usr/bin/shiny-server.sh
RUN chmod +x /usr/bin/shiny-server.sh
CMD ["/usr/bin/shiny-server.sh"]
The image was created without any error but when I run:
docker run --rm -p 3838:3838 [image]
it just runs without the app coming up. Any suggestions/hints?
Many thanks in advance.

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