I am trying to build a mongo 4.4 image based on the official image Dockerfile but I am running into an issue with systemctl not found. The image itself has a line to remove it after setup, but not sure where it came from. Any ideas?
Setting up mongodb-org-database-tools-extra (4.4.0) ...
Setting up librtmp1:amd64 (2.4+20151223.gitfa8646d.1-1) ...
Setting up libkrb5support0:amd64 (1.16-2ubuntu0.1) ...
Setting up krb5-locales (1.16-2ubuntu0.1) ...
Setting up libkeyutils1:amd64 (1.5.9-9.2ubuntu2) ...
Setting up libk5crypto3:amd64 (1.16-2ubuntu0.1) ...
Setting up libkrb5-3:amd64 (1.16-2ubuntu0.1) ...
Setting up libgssapi-krb5-2:amd64 (1.16-2ubuntu0.1) ...
Setting up libcurl4:amd64 (7.58.0-2ubuntu3.10) ...
Setting up mongodb-database-tools (100.1.1) ...
Setting up mongodb-org-mongos (4.4.0) ...
Setting up mongodb-org-tools (4.4.0) ...
Setting up mongodb-org-server (4.4.0) ...
/var/lib/dpkg/info/mongodb-org-server.postinst: 43: /var/lib/dpkg/info/mongodb-org-server.postinst: systemctl: not found
dpkg: error processing package mongodb-org-server (--configure):
installed mongodb-org-server package post-installation script subprocess returned error exit status 127
Setting up mongodb-org-shell (4.4.0) ...
dpkg: dependency problems prevent configuration of mongodb-org:
mongodb-org depends on mongodb-org-server; however:
Package mongodb-org-server is not configured yet.
dpkg: error processing package mongodb-org (--configure):
dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.27-3ubuntu1.2) ...
Errors were encountered while processing:
mongodb-org-server
mongodb-org
[91mE: Sub-process /usr/bin/dpkg returned an error code (1)
[0mThe command '/bin/sh -c set -x && export DEBIAN_FRONTEND=noninteractive && apt-get update && echo "mongodb-org hold" | dpkg --set-selections && echo "mongodb-org-server hold" | dpkg --set-selections && echo "mongodb-org-shell hold" | dpkg --set-selections && echo "mongodb-org-mongos hold" | dpkg --set-selections && echo "mongodb-org-tools hold" | dpkg --set-selections && apt-get install -y ${MONGO_PACKAGE}=$MONGO_VERSION ${MONGO_PACKAGE}-server=$MONGO_VERSION ${MONGO_PACKAGE}-shell=$MONGO_VERSION ${MONGO_PACKAGE}-mongos=$MONGO_VERSION ${MONGO_PACKAGE}-tools=$MONGO_VERSION && rm -f /usr/local/bin/systemctl && rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/mongodb && mv /etc/mongod.conf /etc/mongod.conf.orig' returned a non-zero code: 100
To be precise
RUN ln -s /bin/echo /bin/systemctl
RUN apt-get -qqy install mongodb-org
FL3SH answer works but to convey the meaning more effectively you can create a symbolic link from /bin/systemctl to /bin/true.
/bin/true is a command wich always return 0 (the truthy value of the shell) so it does not fail. It's a standard way to indicate that you want to return true. See this SO post also
The command you need to add in the Dockerfile is:
RUN ln -s /bin/true /usr/local/bin/systemctl
or
RUN ln -s /bin/true /bin/systemctl
The effect is that you trick the post-install script by calling /bin/true instead of /bin/systemctl
You can find the same trick into the official mongodb Dockerfile 4.4 line 91 that haytham linked in his description.
/bin/echo works as well as /bin/true because echo returns 0 as well. You can try it by doing
echo "test"
echo $?
And you'll see 0 as the result of the second echo.
echo ln to /bin/systemctl solves the issue.
Related
Specs: Ubuntu 18.04 Nginx server, Vestacp control panel.
MongoDB was pre-installed in my server, in 3.6.3 version. It was working but I wanted to upgrade it to version 4.4 (current release).
The problem now is that I can't start the mongo service (community edition).
Steps I followed so far:
Stop MongoDB service, Remove packages and remove Data Directories.
sudo service mongod stop
sudo apt-get purge mongodb-org*
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
Trying to install the new version 4.4 the exact steps from the documentation. Below are the commands with an order:
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
sudo apt-get install gnupg
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
sudo apt-get update
sudo apt-get install -y mongodb-org
echo "mongodb-org hold" | sudo dpkg --set-selections
echo "mongodb-org-server hold" | sudo dpkg --set-selections
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
echo "mongodb-org-tools hold" | sudo dpkg --set-selections
ps --no-headers -o comm 1
sudo systemctl start mongod
sudo systemctl daemon-reload
sudo systemctl enable mongod
mongo
Errors:
sudo apt-get update
It throws an error:
Skipping acquire of configured file 'nginx/binary-i386/Packages' as repository 'http://nginx.org/packages/mainline/ubuntu bionic InRelease' doesn't support architecture 'i386'
On the step:
sudo apt-get install -y mongodb-org
E: Sub-process /usr/bin/dpkg returned an error code (1)
On the step:
sudo systemctl start mongod
Failed to start mongod.service: Unit mongod.service not found.
Directories:
/var/lib/mongodb
and
/var/log/mongodb
are not auto-created after the installation and I can't find them on the above paths.
The port I am trying to begin the server is the default 27017 and I set the rules to ufw.
I am tried to find a solution from similar posts but nothing. I'm stuck for two days now.
Any thought or help?
The problem was in uninstallation of previous MongoDB version 3.6.3.
The command in terminal...
sudo apt-get purge mongodb-org*
...Doesn't uninstall all the packages correctly.
The correct uninstallation was to type in the command line:
sudo apt list --installed | grep mongo
...In order to see if there are any packages left from MongoDB. I had 2 packages left that "purge mongodb-org*" couldn't delete.
So the correct removing executions are the below:
sudo apt remove mongodb
sudo apt purge mongodb
sudo apt autoremove
After that, the installation of the new MongoDB version 4.4 was successfully completed without errors!
So I'm having this problem where for some reason I can't install any package on my ubuntu system.
I'm currently on Ubuntu 16.10.
terminal install logs
Update:
I've done entered those commands and got this.
after update and apt-cache
What should I do now?
sudo apt-get install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
After installing the PostgreSQL database server, by default, it creates a user ‘postgres’ with role ‘postgres’. Also creates a system account with the same name ‘postgres’. So to connect to Postgres server, log in to your system as user postgres and connect database.
sudo su - postgres
psql
First do
sudo apt-get update
You should get no errors upon updating. In case you do, then you might have issues with your firewall, or something blocking you from updating repositories. Check the output carefully.
And then search for the correct (exact!) package name using this command:
apt-cache search postgresql
As a last resort you could add external 3rd Party repository as described in this answer. Just remember to use your distribution name instead of "xenial".
It should work.
$ sudo apt-get install postgresql postgresql-client
If you are getting (E: Unable to locate package postgresql-12) while migrating following step may helps you:
sudo apt-get -y install bash-completion wget
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc |
sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql-12 postgresql-client-12
sudo systemctl status postgresql
ref:install postgres12 in ubuntu-18.04
Following Commands worked for me: sudo apt-get install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ lsb_release -cs-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update
sudo apt install postgresql-11 libpq-dev
I'm trying to reinstall mongodb with apt-get install.
But it make error.
chown: invalid group: ‘mongodb:mongodb’
dpkg: error processing package mongodb-server (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mongodb:
mongodb depends on mongodb-server (>= 1:2.4.1-2); however:
Package mongodb-server is not configured yet.
dpkg: error processing package mongodb (--configure):
dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.19-18+deb8u10) ...
Processing triggers for systemd (215-17+deb8u7) ...
Errors were encountered while processing:
mongodb-server
mongodb
E: Sub-process /usr/bin/dpkg returned an error code (1)
I'm using next command but not work.
apt-get --reinstall install mongodb
and
sudo apt-get purge mongodb mongodb-clients mongodb-server mongodb-dev
sudo apt-get autoremove
and install mongodb but it also don't work.
When i install mongodb first,
I use install.sh to install.
#!/bin/bash
if [ $(id -u) != 0 ]; then
exec sudo -- "$0" "$#"
exit
fi
echo "Creating mongodb user"
adduser --firstuid 100 --ingroup nogroup --shell /etc/false --disabled-password --gecos "" --no-create-home mongodb
echo "Installing mongo to /opt/mongo..."
tar xfz mongo.tar.gz -C /opt --owner mongodb
echo "Creating runtime directories under /var"
install -o mongodb -g nogroup -d /var/log/mongodb/
install -o mongodb -g nogroup -d /var/lib/mongodb/
echo "Installing config scripts"
install mongod /etc/init.d
install mongodb.conf /etc
echo "Setting mongod to start on boot"
update-rc.d mongod defaults
echo "Starting mongod"
/etc/init.d/mongod start
echo "done."
How to uninstall mongodb?
from my node scripts I need to execute mongoimport via the exec function from child_process. When it comes to the CI tests in the docker image I run into a problem:
/bin/sh: 1: mongoimport: not found
Now I inserted the installation of mongodb in the drone.yml file:
- apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
- echo "deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.2 main" | tee /etc/apt/sources.list.d/mongodb-org-3.2.list
- apt-get update
- apt-get install -d -y mongodb-org-tools
But still mongoimport isn't found. I even added the root / to the PATH variable or made a
find / -name "mongoimport"
Nothing.
Has anyone an idea, how to get mongoimport working in the docker image?
Thank you.
PS.: Here's the output from apt-get:
$ apt-get install -d -y mongodb-org-tools
Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
mongodb-org-tools
0 upgraded, 1 newly installed, 0 to remove and 102 not upgraded.
Need to get 31.4 MB of archives.
After this operation, 135 MB of additional disk space will be used.
Get:1 http://repo.mongodb.org/apt/debian/ jessie/mongodb-org/3.2/main mongodb-org-tools amd64 3.2.14 [31.4 MB]
Fetched 31.4 MB in 1s (28.2 MB/s)
Download complete and in download only mode
Solved: I tried to install the wrong package.
- apt-get install -d -y mongodb-org-tools
It must be
- apt-get install -y mongodb-org
Then automatically the mongodb-org-tools are installed together with some other packages. Now mongoimport can be used
$ find / -name "mongoimport" -ls > out.txt
$ cat out.txt
2038 10588 -rwxr-xr-x 1 root root 10839312 Jun 13 22:30 /usr/bin/mongoimport
I've got a custom built grafana docker image that I build using
go run build.go build package
This all works fine, and I get a deb image from the process (grafana_4.3.0-1490275845pre1_amd64.deb) as well as a .tar.gz file and an rpm package as well.
When using the dockerfile (essentially copied from grafana/grafana-docker):
FROM debian:jessie
COPY ./grafana.deb /tmp/grafana.deb
RUN apt-get update && \
apt-get -y --no-install-recommends install libfontconfig curl ca-certificates && \
apt-get clean && \
dpkg -i --debug=3773 /tmp/grafana.deb && \
rm /tmp/grafana.deb && \
I get the following error:
dpkg (subprocess): unable to execute installed post-installation script (/var/lib/dpkg/info/grafana.postinst): No such file or directory
dpkg: error processing package grafana (--install):
subprocess installed post-installation script returned error exit status 2
D000001: ensure_diversions: same, skipping
D000002: fork/exec /var/lib/dpkg/info/systemd.postinst ( triggered /etc/init.d )
D000001: ensure_diversions: same, skipping
Errors were encountered while processing:
grafana
Setting up grafana (4.3.0-1490275845pre1) ...
Processing triggers for systemd (215-17+deb8u6) ...
The command '/bin/sh -c apt-get update && apt-get -y --no-install-recommends install libfontconfig curl ca-certificates && apt-get clean && dpkg -i -- debug=3773 --force-all /tmp/grafana.deb && rm /tmp/grafana.deb && curl -L https://github.com/tianon/gosu/releases/download/1.7/gosu-amd64 > /usr/sbin/gosu && chmod +x /usr/sbin/gosu && apt-get remove -y curl && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 1
The obvious issue is (/var/lib/dpkg/info/grafana.postinst): No such file or directory but not knowing anything about dpkg I don't really know where to start trying to debug it. As far as I'm aware, I've not altered the deployment scripts so I'm at a loss to know where the issue has arisen.
As I was developing Grafana on a shared Windows folder, with Grafana running in a Docker container on VirtualBox, it seems that (despite not editing the files) SourceTree or something else edited the source to add Windows new lines which messed up the packaging step. I just used dos2unix to remove newlines and everything started working as expected.
The particular error message was related to newlines in the postinst file, which I debugged manually with bash on the VM.