Couchbase running in a container not accessible - centos

So I've created this Dockerfile:
FROM centos
EXPOSE 7081 8092 11210
RUN yum install -y \
hostname \
initscripts \
openssl098e \
pkgconfig \
sudo \
tar \
wget \
&& wget http://packages.couchbase.com/releases/3.0.2/couchbase-server-enterprise-3.0.2-centos6.x86_64.rpm \
&& yum install -y couchbase-server-enterprise-3.0.2-centos6.x86_64.rpm \
&& rm -f ./couchbase-server-enterprise-3.0.2-centos6.x86_64.rpm \
CMD /opt/couchbase/bin/couchbase-server start -- -noinput
And that seems to be working (running the couchbase server) and to build and run it I do:
docker build -t="my/couchbase" .
docker run -itd --name=couchbase -p 11210:11210 -p 8091:7081 -p 8092:8092 my/couchbase
Now for some reason I can't connect to it via http. I tried to get ip address of the container with docker inspect couchbase | grep IP
and then going to http://containters_ip:7081
It's trying to get there for a very long time, but eventually times out.
What am I doing wrong?

You need EXPOSE 8091 8092 11210 (think of this as "the container listens on these ports") and -p 7081:8091 to get the mapping you seek. In -p it's hostport:containerport order.

Related

New Relic PHP Agent Kubernetes (GKE)

Could you please advise on setting up permissions with the docker file for the www-data user to start PHP agent within the docker container running on GKE. Please advise.
FROM php:7.4-fpm as test
RUN \
curl -L https://download.newrelic.com/php_agent/release/newrelic-php5-10.1.0.313-linux.tar.gz | tar -C /tmp -zx && \
export NR_INSTALL_USE_CP_NOT_LN=1 && \
export NR_INSTALL_SILENT=1 && \
/tmp/newrelic-php5-*/newrelic-install install && \
rm -rf /tmp/newrelic-php5-* /tmp/nrinstall* && \
sed -i \
-e 's/"REPLACE_WITH_REAL_KEY"/"My-Key"/' \
-e 's/newrelic.appname = "PHP Application"/newrelic.appname = "test"/' \
-e 's/;newrelic.daemon.app_connect_timeout =.*/newrelic.daemon.app_connect_timeout=15s/' \
-e 's/;newrelic.daemon.start_timeout =.*/newrelic.daemon.start_timeout=5s/' \
/usr/local/etc/php/conf.d/newrelic.ini
USER www
php app related build. etc....
Thank you very much.
In your docker file you are changing the user to USER www due to that it's not running.
As suggested in error it is expected to run by the root user so you can remove the USER www line from docker and try building a new docker image with --no-cache and it will start working with root.
Official ref : https://docs.newrelic.com/docs/apm/agents/php-agent/advanced-installation/docker-other-container-environments-install-php-agent/

Use local mirror of Alpine when build images of docker-compose instead legacy repositories

Is it possible to use a local repository (mirror) that is used by docker when building a container with docker-compose?
I have a local mirror, and my interest is that when I build a container with docker-compose build, the apk is downloaded from the local mirror, instead of the Internet
Example.
If a local deploy with Dockerfile
FROM alpine:3.13
# Install packages and remove default server definition
RUN apk --no-cache add php8=8.0.2-r0 php8-fpm php8-opcache php8-mysqli php8-json \
php8-openssl php8-curl php8-soap php8-zlib php8-xml php8-phar php8-intl php8-dom php8-xmlreader php8-ctype \
php8-session php8-simplexml php8-mbstring php8-gd nginx supervisor curl php8-exif php8-zip php8-fileinfo \
php8-iconv php8-soap tzdata htop mysql-client php8-pecl-imagick php8-pecl-redis php8-tokenizer php8-xmlwriter \
nano && rm /etc/nginx/conf.d/default.conf
When deploy container with docker-compose build I like that use my local repository of alpine instead any internet mirrors of Alpine such:
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz
(1/124) Installing ca-certificates (20191127-r5)
(2/124) Installing brotli-libs (1.0.9-r3)
(3/124) Installing nghttp2-libs (1.42.0-r1)
...
After read alpine docs Alpine Linux package management I get solution using static IP of local mirror. I tried to use the name of the hostname (repoalpine.test) but I couldn't find how to make the hostname public on the docker network.
RUN apk --no-cache -X http://172.20.0.254/v3.13/main -X http://172.20.0.254/v3.13/community \
add php8=8.0.2-r0 php8-fpm php8-opcache php8-mysqli php8-json \
php8-openssl php8-curl php8-soap php8-zlib php8-xml php8-phar php8-intl php8-dom php8-xmlreader php8-ctype \
php8-session php8-simplexml php8-mbstring php8-gd nginx supervisor curl php8-exif php8-zip php8-fileinfo \
php8-iconv php8-soap tzdata htop mysql-client php8-pecl-imagick php8-pecl-redis php8-tokenizer php8-xmlwriter \
nano && rm /etc/nginx/conf.d/default.conf
Now work
Step 7/22 : RUN apk --no-cache -X http://172.20.0.254/v3.13/main -X http://172.20.0.254/v3.13/community add php8=8.0.2-r0 php8-fpm php8-opcache php8-mysqli php8-json php8-openssl php8-curl php8-soap php8-zlib php8-xml php8-phar php8-intl php8-dom php8-xmlreader php8-ctype php8-session php8-simplexml php8-mbstring php8-gd nginx supervisor curl php8-exif php8-zip php8-fileinfo php8-iconv php8-soap tzdata htop mysql-client php8-pecl-imagick php8-pecl-redis php8-tokenizer php8-xmlwriter nano && rm /etc/nginx/conf.d/default.conf
---> Running in 4f2c6521e6e6
fetch http://172.20.0.254/v3.13/community/x86_64/APKINDEX.tar.gz
...
You need a local Docker Registry

Two docker images into a single docker image [duplicate]

This question already has answers here:
Docker: Combine multiple images
(4 answers)
Closed 2 years ago.
I have a requirement to create a single docker image by merging both "RabbitMQ-management" and "MongoDB" images. Is it possible to do it?
I've tried with below Dockerfile and can able to access RabbitMQ, but mongodb is not working. Could you please help me.
# cat Dockerfile
FROM rabbitmq:3.7.17
RUN rabbitmq-plugins enable --offline rabbitmq_management
# extract "rabbitmqadmin" from inside the "rabbitmq_management-X.Y.Z.ez" plugin zipfile
# see https://github.com/docker-library/rabbitmq/issues/207
RUN apt-get update && apt-get install -y gnupg2
RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 0C49F3730359A14518585931BC711F9BA15703C6 && \
gpg --export $GPG_KEYS > /etc/apt/trusted.gpg.d/mongodb.gpg
ARG MONGO_PACKAGE=mongodb-org
ARG MONGO_REPO=repo.mongodb.org
ENV MONGO_PACKAGE=${MONGO_PACKAGE} MONGO_REPO=${MONGO_REPO}
ENV MONGO_MAJOR 3.4
ENV MONGO_VERSION 3.4.18
RUN echo "deb http://$MONGO_REPO/apt/debian jessie/${MONGO_PACKAGE%-unstable}/$MONGO_MAJOR main" | tee "/etc/apt/sources.list.d/${MONGO_PACKAGE%-unstable}.list"
RUN echo "/etc/apt/sources.list.d/${MONGO_PACKAGE%-unstable}.list"
RUN apt-get update
RUN apt-get install -y ${MONGO_PACKAGE}=$MONGO_VERSION
RUN set -eux; \
erl -noinput -eval ' \
{ ok, AdminBin } = zip:foldl(fun(FileInArchive, GetInfo, GetBin, Acc) -> \
case Acc of \
"" -> \
case lists:suffix("/rabbitmqadmin", FileInArchive) of \
true -> GetBin(); \
false -> Acc \
end; \
_ -> Acc \
end \
end, "", init:get_plain_arguments()), \
io:format("~s", [ AdminBin ]), \
init:stop(). \
' -- /plugins/rabbitmq_management-*.ez > /usr/local/bin/rabbitmqadmin; \
[ -s /usr/local/bin/rabbitmqadmin ]; \
chmod +x /usr/local/bin/rabbitmqadmin; \
apt-get update; apt-get install -y --no-install-recommends python ca-certificates; rm -rf /var/lib/apt/lists/*; \
rabbitmqadmin --version
EXPOSE 15671 15672 27017
I'm using below command to run RabbitMQ (it is working)
# docker run -it -p 15672:15672 -p 5672:5672 --hostname my-rabbitmq image
Command to start Mongodb container (it is not working)
docker run -d -v /tmp/mongodb:/data/db -p 27017:27017 image mongod
It is not impossible to achieve what you are asking, but I would say it's not the correct way of doing it. Docker provides isolation, and states that it should be one process per container. (should, not must).
If you follow this concept, it's easy to use other tools to bring up multiple containers together. For example, instead of complicated Dockerfile that merge two images you can specify a nice docker-compose.yml:
version: '3'
services:
mongo:
image: mongod
volumes:
- /tmp/mongodb:/data/db
ports:
- "27017:27017"
rabbitmq:
image: rabbitmq
ports:
- "15672:15672"
- "5672:5672"
depends_on:
- mongo
Which is more readable IMO, and probably achieve the same outcome.

Facing issues due to ownership on mounted folder with Docker

Following command works fine
sudo docker run -d -p 8080:80 --name openproject -e SECRET_KEY_BASE=somesecret \
-v /var/lib/openproject/pgdata:/var/lib/postgresql/9.6/main \
-v /var/lib/openproject/logs:/var/log/supervisor \
-v /var/lib/openproject/static:/var/db/openproject \
openproject/community:8
But this command doesn't start container
sudo docker run -d -p 8080:80 --name openproject -e SECRET_KEY_BASE=somesecret \
-v ~/Dropbox/openproject/pgdata:/var/lib/postgresql/9.6/main \
-v /var/lib/openproject/logs:/var/log/supervisor \
-v ~/Dropbox/openproject/static:/var/db/openproject \
openproject/community:8
I've also tried making /var/lib/openproject/pgdata symlink to ~/Dropbox/openproject/pgdata. But it also didn't work.
Docker logs say, PostgreSQL Config owner (postgres:102) and data owner (app:1000) do not match, and config owner is not root.
Is there any way to mount non-root folder on root folder inside the docker container and solve this issue?

eclipse che docker - can not create workspace - <no value>/lib/linux_amd64/terminal

I tried so set up eclipse che as described in https://eclipse.org/che/docs/setup/docker/
with the following command:
docker run -p 8080:8080 \
--name che \
--rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /myimage \
eclipse/che-server:5.0.0-latest
che runs successfully, but during the creation of the workspace the following error message appears:
Caused by: org.eclipse.che.api.core.ServerException: Error response from docker API, status: 500, message: create <no va
lue>/lib/linux_amd64/terminal: "<no value>/lib/linux_amd64/terminal" includes invalid characters for a local volume name
, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intented to pass a host directory, use absolute path
I experience this both on a debian and on a windows instance. I'm quite new to docker. What could be the cause?
I did face the same problem all through and realized that I had done my installations wrong. Following the instructions on the eclipse che website can be quite challenging if you are a newbie to it.
Kindly follow the following steps to install eclipse che using docker image and the issue you are currently facing will be gone.
(The following commands are with the assumption that you are on Debian Distribution. I am on Ubuntu 16.04)
1. Install JDK on the machine.
$ sudo apt-get update
$ sudo apt-get install default-jdk
2. Install Docker
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
$ sudo apt-get update
$ sudo apt-get install -y docker-ce
3. Verify if docker has successfully installed
$ systemctl status docker
$ docker -v
$ sudo docker info
$ sudo docker hello-world
4. Install Eclipse CHE
$ cd ~
$ sudo mkdir eclipseche
$ sudo docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v ~/eclipseche:/data eclipse/che start
Docker is complaining about the syntax of this:
-v /myimage
As it's documented, they recommend to put the /data of che to a volume, in order to persist data between docker runs.
So, put this volume:
-v $(pwd)/che-data:/data
Resulting in this command:
docker run -p 8080:8080 \
--name che \
--rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(pwd)/che-data:/data \
eclipse/che-server:5.0.0-latest
$(pwd)/che-data is the directory in your host machine where the che's data will be saved.
/data is the directory inside che container, linked to ./che-data outside container.
-v /myimage \ is wrong :/data is correct