How to connect to squid proxy docker container to use ftp-proxy? - docker

I am using squid proxy server in docker container to use ftp-proxy. As following. https://hub.docker.com/r/sameersbn/squid/
My modified docker file
FROM ubuntu:bionic-20190612
ENV SQUID_VERSION=3.5.27 \
SQUID_CACHE_DIR=/var/spool/squid \
SQUID_LOG_DIR=/var/log/squid \
SQUID_USER=proxy
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y squid=${SQUID_VERSION}* \
&& rm -rf /var/lib/apt/lists/*
ENV http_proxy=test.rebex.net \
https_proxy=test.rebex.net \
ftp_proxy=test.rebex.net:21
COPY entrypoint.sh /sbin/entrypoint.sh
RUN chmod 755 /sbin/entrypoint.sh
EXPOSE 3128/tcp
ENTRYPOINT ["/sbin/entrypoint.sh"]
Running the docker container with command:
docker run --name squid \
--publish 3128:3128 \
squid-proxy
I want to connect to the ftp test.rebex.net with my filezilla through the running docker. When I try to connect my filezilla ftp client to localhost:3128, the connection fails. How do I connect to the ftp server through squid ftp-proxy in docker?

Related

Connecting Rstudio and SFTP docker containers directly

I'm trying to run RStudio Server in a docker container. Users will connect to this docker container and use RStudio via the internet.
The built-in mechanism for uploading and downloading files in Rstudio is very slow so I'd also like to run an SFTP server in a separate container.
I'm trying to link the two containers using Docker Volumes but I'm having some trouble. Here's is how I'm trying to run the two images.
I'm running the FTP sever using:
docker run -p 2222:22 -v /home/rstudio --name ftpserver -d atmoz/sftp rstudio:foo:1001
Then I'm trying to connect to the same directory in RStudio by doing:
docker run -d -p 8787:8787 -e PASSWORD=foo --volumes-from ftpserver --name rstudio r-studio-bio:Dockerfile
This causes RStudio to give an error
RStudio Initialization Error. Unable to connect to service.
Likewise I'm unable to upload to the FTP server because it's saying I lack the proper permissions.
The FTP server image is here : https://hub.docker.com/r/atmoz/sftp/
The RStudio-Server Dockerfile is:
# See the following for more info:
# https://hub.docker.com/r/pgensler/sandboxr/
# https://www.rocker-project.org/images/
# https://hub.docker.com/r/rocker/rstudio
FROM rocker/tidyverse
LABEL maintainer="Alex"
#
RUN mkdir -p $HOME/.R
RUN mkdir $HOME/Rlibs
ENV R_LIBS $HOME/Rlibs
# COPY R/Makevars /root/.R/Makevars
RUN apt-get update -qq \
&& apt-get -y --no-install-recommends install \
curl \
clang \
ccache \
default-jdk \
default-jre \
wget \
systemd \
# openssh-server \
&& R CMD javareconf \
# && systemctl ssh start \
# && systemctl enable ssh \
&& rm -rf /var/lib/apt/lists/*
RUN wget \
https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& mkdir /root/.conda \
&& bash Miniconda3-latest-Linux-x86_64.sh -b \
&& rm -f Miniconda3-latest-Linux-x86_64.sh
# # Install additional R packages
RUN Rscript -e "BiocManager::install()"
RUN Rscript -e "BiocManager::install('multtest')"
RUN Rscript -e "install.packages('Seurat')"

running a phpUnit test within a docker container

i want to run a specific version of phpUnit WITHIN a docker container. This container will use a specific version of php. i.e
php:5.6-apache
Its a Laravel application. i have install phpunit via composer on the hostfiles and then used the volume command to transfer this to the container.
my composer.json file has following entry:
"require-dev": {
"phpunit/phpunit": "^5.0"
},
This is my docker run command to run the test on my testdev container:
docker run --rm -it -v ~/Users/mow/Documents/devFolder/testdev:/app testdev_php "php ./vendor/bin/phpunit"
This returns the error:
exec: fatal: unable to exec php ./vendor/bin/phpunit: No such file or directory
i am unclear why it says this because te vendor directory is at the root of my site directory.
this is my dockerfile
FROM php:5.6-apache
ENV S6_OVERLAY_VERSION 1.11.0.1
RUN apt-get update && apt-get install -y \
libldap2-dev \
git \
--no-install-recommends \
&& rm -r /var/lib/apt/lists/* \
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
&& docker-php-ext-install ldap \
&& docker-php-ext-install mysqli pdo pdo_mysql
#install xdebug
RUN git clone https://github.com/xdebug/xdebug.git \
&& cd xdebug \
&& git checkout tags/XDEBUG_2_5_5 \
&& phpize \
&& ./configure --enable-xdebug \
&& make \
&& make install
RUN a2enmod rewrite
COPY ./docker/rootfs /
COPY . /app
WORKDIR /app
ENTRYPOINT ["/init"]
I guess the real question is this: what is the correct way to run a phpUnit test within a docker container so that its subject to the php version within that container.
In the Entrypoint, you need to ran composer install to install the requisite packages that will be available in the docker container
without Dockerfile use this code in windows PowerShell :
docker run --rm -v ${pwd}:/app composer:latest require --dev phpunit/phpunit:^8
create composer container to install phpunit then remove the container.
note: in windows Command %cd% / in windows PowerShell ${pwd} / in linux $PWD
then Create new PHP container with copy all fills include phpuint feamework
docker run -d -p 80:80 --name my-php-apache -v ${pwd}:/var/www/html php:7.4.0-apache
to active autoload file, and testing please visit this Page

How to add jupyter to rocker image?

I'm new to docker and I'm trying to add jupyter and python to my docker image based on Rocker (I want to have both python and R). I was able to install python3and jupyter with the dependencies. Image was created successfully. After running container I have access to RStudio server on port 7878, but unfortunately on port 8888 jupyter is not working.
My Dockerfile looks like this :
FROM rocker/rstudio:3.5.0
# Basic dependencies
RUN apt-get update && apt-get install -y \
libcurl4-gnutls-dev \
libssl-dev \
libpng-dev \
vim \
nano \
libxml2 \
libxml2-dev \
curl \
gnupg2 \
build-essential libssl-dev \
libpq-dev \
ssh
SHELL ["/bin/bash", "-c"]
# Install python3 and pip3
RUN apt-get update && apt-get install -y python3 \
python3-pip \
build-essential
# Install jupyter
RUN pip3 install jupyter
EXPOSE 8888
RUN mkdir /notebooks
CMD jupyter notebook --no-browser --ip 0.0.0.0 --allow-root --port 8888 /notebooks
CMD ["/init"]
Build and run:
docker build -f Dockerfile -t user/my_docer:1.0 .
docker run -d --name my_docker -p 8787:8787 -p 8888:8888 -v `pwd`:/mnt user/my_docer:1.0
You cannot use several CMD instructions - the second one overrides the first. If you need several processes to run in your container, which is treated as a bad practice, better use software like supervisord.
Another option is putting all stuff in a single CMD instruction like
CMD ["/bin/bash", "-c", "'jupiter blahblah && /init'"]

Docker Container port issue: Not able to access tomcat url using host ip

I am new to Docker, I have setup Docker Container on an Amazon Linux box.
I have a docker file which installs tomcat java and a war.
I can see all the installations present in the docker container when I navigate through the container in the exact folders I have mentioned in the Docker file.
When I run the Docker container it says tomcat server has started and I have also tailed the logs so I can see the service is running.
But when I open the host IP URL and 8080 port it says URL can't be reached.
These are the commands to build and run the file which works fine and I can see the status as running.
docker build -t friendly1 .
docker run -p 8080:8080 friendly1
What am I missing here? Request some help on this.
FROM centos:latest
RUN yum -y update && \
yum -y install wget && \
yum -y install tar && \
yum -y install zip unzip
ENV JAVA_HOME /opt/java/jdk1.7.0_67/
ENV CATALINA_HOME /opt/tomcat/apache-tomcat-7.0.70
ENV SAVIYNT_HOME /opt/tomcat/apache-tomcat-7.0.70/webapps
ENV PATH $PATH:$JAVA_HOME/jre/jdk1.7.0_67/bin:$CATALINA_HOME/bin:$CATALINA_HOME/scripts:$CATALINA_HOME/apache-tomcat-7.0.70/bin
ENV JAVA_VERSION 7u67
ENV JAVA_BUILD 7u67
RUN mkdir /opt/java/
RUN wget https://<S3location>/jdk-7u67-linux-x64.gz && \
tar -xvf jdk-7u67-linux-x64.gz && \
#rm jdk*.gz && \
mv jdk* /opt/java/
# Install Tomcat
ENV TOMCAT_MAJOR 7
ENV TOMCAT_VERSION 7.0.70
RUN mkdir /opt/tomcat/
RUN wget https://<s3location>/apache-tomcat-7.0.70.tar.gz && \
tar -xvf apache-tomcat-${TOMCAT_VERSION}.tar.gz && \
#rm apache-tomcat*.tar.gz && \
mv apache-tomcat* /opt/tomcat/
RUN chmod +x ${CATALINA_HOME}/bin/*sh
WORKDIR /opt/tomcat/apache-tomcat-7.0.70/
CMD "startup.sh" && tail -f /opt/tomcat/apache-tomcat-7.0.70/logs/*
EXPOSE 8080

Dockerfile with LAMP running (Ubuntu)

I'm trying to create a Docker (LAMP) image with the following
Dockerfile:
FROM ubuntu:latest
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
apache2 \
mysql-server \
php7.0 \
php7.0-bcmath \
php7.0-mcrypt
COPY start-script.sh /root/
RUN chmod +x /root/start-script.sh && /root/start-script.sh
start-script.sh:
#!/bin/bash
service mysql start
a2enmod rewrite
service apache2 start
I build it with:
docker build -t resting/ubuntu .
Then run it with:
docker run -it -p 8000:80 -p 5000:3306 -v $(pwd)/html:/var/www/html resting/ubuntu bash
The problem is, the MYSQL and Apache2 service are not started.
If I run /root/start-script.sh manually in the container, port 80 maps fine to port 8000, but I couldn't connect to MYSQL with 127.0.0.1:5000.
How can I ensure that the services are running when I spin up a container with the image, and map MYSQL out to my host machine?
You need to change the execution of the script to a CMD instruction.
FROM ubuntu:latest
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
apache2 \
mysql-server \
php7.0 \
php7.0-bcmath \
php7.0-mcrypt
COPY start-script.sh /root/
RUN chmod +x /root/start-script.sh
CMD /root/start-script.sh
Althought this works, this is not the right way to manage containers. You should have one container for your Apache2 and another one for MySQL.
Take a look to this article that build a LAMP stack using Docker-Compose: https://www.kinamo.be/en/support/faq/setting-up-a-development-environment-with-docker-compose
you need multiple images - one for each service or app.
A Docker container is not a virtual machine in which you run an entire stack. It is a virtual application, running one primary process.
If you need php, apache and mysql, then you will need 3 docker containers. one for your php app, one for apache and one for mysql.

Resources