I cannot send email in Laradock environment - laravel

So, I use Laradock for my PHP project development environment. I have issue when send email to mailtrap and have this error:
sh: 1: /usr/sbin/sendmail: not found
How to solve this? or is there any alternative to mail testing in Laradock the best practice and ways?
I already try to install sendmail in php-fpm dockerfile apt-get install -y sendmail && \, and then re-build the container, seems the sendmail is installed as seen in the log, then restart the container, it still has same error:
sh: 1: /usr/sbin/sendmail: not found
my php-fpm/Dockerfile
...
# always run apt update when start and after add new source list, then clean up at end.
RUN set -xe; \
apt-get install -y sendmail && \
apt-get update -yqq && \
pecl channel-update pecl.php.net && \
apt-get install -yqq \
apt-utils \
#
#--------------------------------------------------------------------------
# Mandatory Software's Installation
#--------------------------------------------------------------------------
#
# Mandatory Software's such as ("mcrypt", "pdo_mysql", "libssl-dev", ....)
# are installed on the base image 'laradock/php-fpm' image. If you want
# to add more Software's or remove existing one, you need to edit the
# base image (https://github.com/Laradock/php-fpm).
#
# next lines are here becase there is no auto build on dockerhub see https://github.com/laradock/laradock/pull/1903#issuecomment-463142846
libzip-dev zip unzip && \
docker-php-ext-configure zip --with-libzip && \
# Install the zip extension
docker-php-ext-install zip && \
php -m | grep -q 'zip'
...
I expect the mail sent to my mailtrap, It's once succeed when I used Wampserver

Related

How can I run a custom docker image with multiple Lambda handlers?

This is my dockerfile. I have also a app.py file with two handlers and I need to be able to run one of them based of a variable or similar. Right now I run only lambda.handler1, but also I want to run lambda.handler2
# Define global args
ARG FUNCTION_DIR="/home/app/"
ARG RUNTIME_VERSION="3.8"
# Bundle base image + runtime
FROM python:${RUNTIME_VERSION}-buster
# Include global args
ARG FUNCTION_DIR
ARG RUNTIME_VERSION
# Install aws-lambda-cpp build dependencies
RUN apt-get update && \
apt-get install -y \
g++ \
make \
cmake \
unzip \
libcurl4-openssl-dev
# Install OCR build dependencies
RUN apt-get update \
&& apt-get install -y tesseract-ocr tesseract-ocr-spa \
&& apt-get install -y poppler-utils
RUN apt-get update \
&& apt-get install libgl1 -y
RUN python${RUNTIME_VERSION} -m pip install --upgrade pip
RUN python${RUNTIME_VERSION} -m pip install tesseract pillow pytesseract
# Copy handler function
RUN mkdir -p ${FUNCTION_DIR}
COPY app/* ${FUNCTION_DIR}
# Install Lambda Runtime Interface Client for Python
RUN python${RUNTIME_VERSION} -m pip install awslambdaric --target ${FUNCTION_DIR}
# Install the function's dependencies
RUN python${RUNTIME_VERSION} -m pip install -r ${FUNCTION_DIR}/docker-requirements.txt
# Set working directory to function root directory
WORKDIR ${FUNCTION_DIR}
# (Optional) Add Lambda Runtime Interface Emulator and use a script in the ENTRYPOINT for simpler local runs
ADD https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie /usr/bin/aws-lambda-rie
COPY entry.sh /
RUN chmod 755 /usr/bin/aws-lambda-rie /entry.sh
ENTRYPOINT [ "/entry.sh"]
CMD [ "app.lambda_handler1" ]

Dockerfile | => ERROR [base 2/7] RUN apt-get update -y && apt-get -y --no-install-recommends install curl wget && rm -rf /var/lib/apt/lists/* [duplicate]

I'm trying to build a docker image but it throws an error and I can't seem to figure out why.
It is stuck at RUN apt-get -y update with the following error messages:
4.436 E: Release file for http://security.debian.org/debian-security/dists/buster/updates/InRelease is not valid yet (invalid for another 2d 16h 26min 22s). Updates for this repository will not be applied.
4.436 E: Release file for http://deb.debian.org/debian/dists/buster-updates/InRelease is not valid yet (invalid for another 3d 10h 28min 24s). Updates for this repository will not be applied.
executor failed running [/bin/sh -c apt-get -y update]: exit code: 100
Here's my docker file:
FROM python:3.7
# Adding trusting keys to apt for repositories
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
# Adding Google Chrome to the repositories
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
# Updating apt to see and install Google Chrome
RUN apt-get -y update
# Magic happens
RUN apt-get install -y google-chrome-stable
# Installing Unzip
RUN apt-get install -yqq unzip
# Download the Chrome Driver
RUN CHROMEDRIVER_RELEASE=$(curl http://chromedriver.storage.googleapis.com/LATEST_RELEASE) && \
echo "Chromedriver latest version: $CHROMEDRIVER_RELEASE" && \
wget --quiet "http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_RELEASE/chromedriver_linux64.zip" && \
unzip chromedriver_linux64.zip && \
rm -rf chromedriver_linux64.zip && \
mv chromedriver /usr/local/bin/chromedriver && \
chmod +x /usr/local/bin/chromedriver && \
chromedriver --version
# Set display port as an environment variable
ENV DISPLAY=:99
WORKDIR /
COPY requirements.txt ./
RUN pip install --upgrade pip && pip install -r requirements.txt
COPY . .
RUN pip install -e .
What is happening here?
In my case, docker was still using the cached RUN apt update && apt upgrade command, thus not updating the package sources.
The solution was to build the docker image once with the --no-cache flag:
docker build --no-cache .
If you are using docker desktop, please check if enough resources are set in settings/preferences.
Eg. memory and disk requirement
It's answered here https://askubuntu.com/questions/1059217/getting-release-is-not-valid-yet-while-updating-ubuntu-docker-container
Correct your system clock. (in comments I also suggested checking for a mismatch between clock and your timezone too)
I get this ERROR: executor failed running [...]: exit code: 100 error message when I mistyped the name of a package.
This was in my Dockerfile:
RUN sudo apt-get update; \
sudo apt-get -y upgrade; \
sudo apt-get install -y gnupg2 wget lsb_release
instead of this:
RUN sudo apt-get update; \
sudo apt-get -y upgrade; \
sudo apt-get install -y gnupg2 wget lsb-release
(see the difference between the underscore and the dash.)
Fixing the package name solved the problem.
This happens specific to OS also.
I had same issues running MariaDB on my Windows 10.
Check for Docker Settings:
{
"registry-mirrors": [],
"insecure-registries": [],
"debug": false,
"experimental": false,
"features": {
"buildkit": true
},
"builder": {
"gc": {
"enabled": true,
"defaultKeepStorage": "20GB"
}
}
}
Remove below block, and it should work:
"features": {
"buildkit": true
},
I had this error and I think it was because I installed buildx but the version of the plugin didn't match my docker installation. Uninstalling buildx resolved the issue for me:
docker buildx uninstall
For me adding this to the Dockerfile did the job:
RUN apk add --update linux-headers;

E: Package 'mysql-client' has no installation candidate in php-fpm image build using docker compose

Im fairly new to docker and so im trying to learn more about it using a laravel project, im following this tutorial:
https://www.digitalocean.com/community/tutorials/how-to-set-up-laravel-nginx-and-mysql-with-docker-compose
Ive adjusted the Dockerfile a bit from what the tutorial has but even the tutorial file causes the same result.
FROM php:7.3-fpm
# Copy composer.lock and composer.json
COPY composer.lock composer.json /var/www/
# Install dependencies
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
apt-get update && apt-get install -y mysql-client \
RUN npm install -g npm
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install extensions
RUN docker-php-ext-install pdo pdo_mysql
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www
# Copy existing application directory contents
COPY . /var/www
# Copy existing application directory permissions
COPY --chown=www:www . /var/www
# Change current user to www
USER www
# Set working directory
WORKDIR /var/www
# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]
But i keep getting the following error when i run docker-compose up -d:
E: Package 'mysql-client' has no installation candidate
ERROR: Service 'app' failed to build: The command '/bin/sh -c curl -sL https://deb.nodesource.com/setup_10.x | bash - && apt-get update && apt-get install -y mysql-client nodejs build-essential vim git curl' returned a non-zero code: 100
Am i missing something?
I expected this to work since i am running apt-get update before installing mysql-client.
Thanks.
php:7.3-fpm now use Debian 10 (Buster) as its base image and Buster ships with MariaDB, so just replace mysql-client with mariadb-client should fix it.
If you still want to use the mysql client, it's called default-mysql-client now.
php:7.2-apache triggers the error as well, but I resolve it using php:7.2.18-apache
it worked for me: sudo apt-get update && apt-get install -y git curl libmcrypt-dev default-mysql-client
or alternatively apt-cache search mysql-server
find out your servers then sudo apt-get install default-mysql-server default-mysql-server-core mariadb-server-10.6 mariadb-server-core-10.6
in my case it was the above codes

Install oracle client in docker container

I am using alpine linux as a base image, and I need to install an oracle client native library. I believe you can download from here:
https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
it looks like I have to login to download, does anyone know how to download a zip file of the client lib without login?
does anyone know how to install the client library properly in a bash script or dockerfile?
I have figure out some different way to install Oracle instant client in ubuntu Docker, it might help others
Follow these simple steps:
Download oracle instant client (.rpm file) from oracle official download center
Convert into .deb (you can use apt-get install alien ) and move somewhere in your working directory.
Now Update your Dockerfile and make build
RUN apt-get update
WORKDIR /opt
ADD ./ORACLE-INSTANT-CLIENT.deb /opt
#if libaio also required
RUN apt-get install libaio1
RUN dpkg -i oracle-instantclient.deb
Here is a working solution for the official PHP-FPM images based on Debian 10 (Buster). The following Dockerfile installs the Oracle Instant Client 18.5 (basiclite and devel) using the RPM packges and alien.
As Christopher Jones wrote the files can currently be downloaded without an Oracle account.
FROM php:7.2.32-fpm
# see https://help.ubuntu.com/community/Oracle%20Instant%20Client
RUN apt-get update && apt-get install -y --no-install-recommends alien libaio1 wget && \
wget https://download.oracle.com/otn_software/linux/instantclient/185000/oracle-instantclient18.5-basiclite-18.5.0.0.0-3.x86_64.rpm && \
wget https://download.oracle.com/otn_software/linux/instantclient/185000/oracle-instantclient18.5-devel-18.5.0.0.0-3.x86_64.rpm && \
alien -i oracle-instantclient18.5-basiclite-18.5.0.0.0-3.x86_64.rpm && \
alien -i oracle-instantclient18.5-devel-18.5.0.0.0-3.x86_64.rpm
ENV LD_LIBRARY_PATH="/usr/lib/oracle/18.5/client64/lib:${LD_LIBRARY_PATH}"
If you want to download oracle at runtime then you can run the below commands
FROM ruby:3.0
ENV LD_LIBRARY_PATH=/opt/oracle/instantclient_21_4
RUN apt-get update && \
apt-get install -y libpq-dev zlib1g-dev build-essential shared-mime-info libaio1 libaio-dev unzip wget --no-install-recommends && \
wget https://download.oracle.com/otn_software/linux/instantclient/214000/instantclient-sdk-linux.x64-21.4.0.0.0dbru.zip && \
wget https://download.oracle.com/otn_software/linux/instantclient/214000/instantclient-sqlplus-linux.x64-21.4.0.0.0dbru.zip && \
wget https://download.oracle.com/otn_software/linux/instantclient/214000/instantclient-basic-linux.x64-21.4.0.0.0dbru.zip && \
mkdir -p /opt/oracle && \
cp instantclient-* /opt/oracle/ && \
cd /opt/oracle/ && \
unzip instantclient-basic-linux.x64-21.4.0.0.0dbru.zip && \
unzip instantclient-sdk-linux.x64-21.4.0.0.0dbru.zip && \
unzip instantclient-sqlplus-linux.x64-21.4.0.0.0dbru.zip && \
rm -rf /var/lib/apt/lists/* instantclient-basic-linux.x64-21.4.0.0.0dbru.zip instantclient-sdk-linux.x64-21.4.0.0.0dbru.zip instantclient-sqlplus-linux.x64-21.4.0.0.0dbru.zip && \
apt -y clean && \
apt -y remove wget unzip && \
apt -y autoremove && \
rm -rf /var/cache/apt
You can download the specific version of instantclient by specifying the version above
These two packages are require for ruby-oci if you are using ruby on rails application
libaio1
libaio-dev
You don't want to use Alpine Linux, since you will need to hack it and it could become unstable. See https://stackoverflow.com/a/53291026/4799035 for more comments.
Also see https://github.com/oracle/docker-images/blob/master/OracleInstantClient/dockerfiles/19/Dockerfile which doesn't need any login.
In summary, on Oracle Linux 7:
yum -y install oracle-release-el7
yum -y install oracle-instantclient19.3-basic && rm -rf /var/cache/yum
Update: Oracle has Docker images at https://github.com/oracle/docker-images/pkgs/container/oraclelinux7-instantclient and https://github.com/oracle/docker-images/pkgs/container/oraclelinux8-instantclient which can be pulled like:
docker pull ghcr.io/oracle/oraclelinux7-instantclient:21
and
docker pull ghcr.io/oracle/oraclelinux8-instantclient:21

Saving files on Mac OSX host to Docker container (auto-reloading)

This question has been asked here in many ways, but none of them seemed to be exactly what I'm looking for. Note: I'm totally new to Docker.
I've currently got a Docker image ("padcrawler") on my Mac, which is an image built off of scrapinghub/splash.
I'm basically just trying to make it so that any changes I make on my host machine (Mac), are automatically updated within the container. I'm using docker-machine and NOT boot2docker.
This is my Dockerfile:
FROM scrapinghub/splash:latest
# Update UBUNTU base image and install deps
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y \
build-essential \
ca-certificates \
gcc \
git \
libpq-dev \
make \
libxml2-dev \
libxslt-dev \
libssl-dev \
libffi-dev \
zlib1g-dev \
python-pip \
python \
python-dev \
ssh \
&& apt-get autoremove \
&& apt-get clean
RUN mkdir -p /usr/src/pad
WORKDIR /usr/src/pad
# Copy over everything to container directory
COPY . /usr/src/pad
# Install Python (2.7) deps
RUN /usr/bin/pip install -r /usr/src/pad/requirements.txt
# Launch pad-crawler upon docker container bootup
ENTRYPOINT /usr/src/pad/start
I'm also using docker-compose and this is my yml file:
version: '2'
services:
crawler:
build: .
volumes:
- ".:/usr/src/pad"
image: padcrawler
However, I'm still unable to get any host file changes to automatically sync with the mounted volume in the container. Obviously it's annoying and frustrating to have to manually copy over the changes every-time. Is there a bigger issue here? I'm using Docker totally wrong?

Resources