Did you try service mongod... or service mongodb .... ? See https://allthings.how/how-to-fix-systemctl-command-not-found-error-in-linux/ and https://www.baeldung.com/linux/differences-systemctl-service
How to use systemctl commands under docker ?
I have installed mongodb under docker and in phpinfo output I see :
mongodb
MongoDB support enabled
MongoDB extension version 1.15.0
...
But none of commands like
systemctl restart mongod
OR
systemctl status mongod
Works for me as I got bash error that systemctl command not found Searching in net I found topics with using service or systemd commands, but none was found on my os
I installed docker from docker-compose.yml with lines :
FROM php:8.1.6-apache
RUN apt-get update && \
apt-get install --assume-yes --no-install-recommends --quiet \
curl \
wget \
gnupg
RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | apt-key add -
RUN echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-6.0.list
I have :
# uname -a
Linux bf247894482b 5.15.0-53-generic #59~20.04.1-Ubuntu SMP Thu Oct 20 15:10:22 UTC 2022 x86_64 GNU/Linux
Which command have I to use run restart mongod ?
Thanks in advance!
I tried both and mongod and mongodb - erorr in both cases.
In provided link I found systemd mentioned and added it to my Dockerfile.yml, but in bash I have :
systemd restart mongod
Excess arguments.
# systemctl restart mongodb
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
# systemd restart mongod
Excess arguments.
# dpkg -l | grep systemd
ii libsystemd0:amd64 247.3-7+deb11u1 amd64 systemd utility library
ii systemd 247.3-7+deb11u1 amd64 system and service manager
# systemd restart mongodb
Excess arguments.
Is command systemd valid in my case? If yes, how t9o use it?
@PetroGromovo Did you try sudo service mongod restart with or without sudo using the service wrapper?
@rhand yes and I got :
$ docker-compose exec web bash
# sudo service mongod restart
bash: sudo: command not found
# service mongod restart
mongod: unrecognized service
# service mongodb restart
mongodb: unrecognized service
@PetroGromovo Does seem System V Init and service wrapper work now.. just not the commands used. Try sudo service mongodb status or sudo service mongod status to check status.
Things depend on MongoDB version and OS and you could double check also:
If you are unsure which init system your platform uses, run the following command:
ps --no-headers -o comm 1
https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/
But again System V seems to be active.
You could even check logs doing tail /var/log/mongodb/mongod.log Might be some clues there.
Update
Thinking some more and you should at least need this:
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
and I only saw you adding the deb package to sources list. perhaps you never really installed the package.
@rhand 1) I got next results in bash:
# sudo service mongodb status
bash: sudo: command not found
# service mongodb status
mongodb: unrecognized service
# ps --no-headers -o comm 1
apache2
# tail /var/log/mongodb/mongod.log
tail: cannot open '/var/log/mongodb/mongod.log' for reading: No such file or directory
# /var/log/mongodb/
bash: /var/log/mongodb/: No such file or directory
-
which commands have I to run to be sure that System V is active ?
-
I have added mongo and my full Dockerfile.yml has mongo refers :
FROM php:8.1.6-apache
RUN apt-get update && \
apt-get install --assume-yes --no-install-recommends --quiet \
curl \
wget \
systemd \
gnupg
RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | apt-key add -
RUN echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-6.0.list
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions \
&& install-php-extensions mongodb
RUN apt-get update && \
apt-get install --assume-yes --no-install-recommends --quiet \
python \
apt-transport-https \
libfreetype6-dev \
libwebp-dev \
libjpeg62-turbo-dev \
libpng-dev \
libzip-dev \
nano \
mc \
git-core \
libmagickwand-dev \
libsodium-dev \
build-essential \
libnotify-bin \
openssl \
libssl-dev \
libgmp-dev \
libldap2-dev \
netcat \
locate \
&& git clone https://github.com/nodejs/node.git && \
cd node \
&& git checkout v14.18.0 \
&& ./configure \
&& make \
&& make install
RUN apt-get install -y mongodb-org
RUN pecl install imagick \
&& docker-php-ext-enable imagick
RUN npm install cross-env
RUN npm install -g yarn
RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp --with-jpeg
RUN docker-php-ext-install gd
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install pdo zip gmp bcmath pcntl ldap sysvmsg exif \
&& a2enmod rewrite
RUN apt-get install -y grep mlocate
RUN docker-php-ext-install ldap sodium
COPY virtualhost.conf /etc/apache2/sites-enabled/000-default.conf
You all mongo options set. Did I miss some commands ?
- Checking logs in hosting kubuntu 20.04 I see :
docker logs --tail=50 MngProducts_mongodb
{"t":{"$date":"2023-02-08T20:54:23.016+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"7F617D628E40","b":"7F617D5FF000","o":"29E40","s":"__libc_start_main","s+":"80"}}}
{"t":{"$date":"2023-02-08T20:54:23.016+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"55EA52E19A95","b":"55EA50CFF000","o":"211AA95","s":"_start","s+":"25"}}}
{"t":{"$date":"2023-02-08T20:55:23.761+00:00"},"s":"I", "c":"NETWORK", "id":4915701, "ctx":"main","msg":"Initialized wire specification","attr":{"spec":{"incomingExternalClient":{"minWireVersion":0,"maxWireVersion":17},"incomingInternalClient":{"minWireVersion":0,"maxWireVersion":17},"outgoing":{"minWireVersion":6,"maxWireVersion":17},"isInternalClient":true}}}
{"t":{"$date":"2023-02-08T20:55:23.763+00:00"},"s":"I", "c":"CONTROL", "id":23285, "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2023-02-08T20:55:23.763+00:00"},"s":"I", "c":"NETWORK", "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
{"t":{"$date":"2023-02-08T20:55:23.764+00:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationDonorService","namespace":"config.tenantMigrationDonors"}}
{"t":{"$date":"2023-02-08T20:55:23.764+00:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationRecipientService","namespace":"config.tenantMigrationRecipients"}}
{"t":{"$date":"2023-02-08T20:55:23.764+00:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"ShardSplitDonorService","namespace":"config.tenantSplitDonors"}}
{"t":{"$date":"2023-02-08T20:55:23.764+00:00"},"s":"I", "c":"CONTROL", "id":5945603, "ctx":"main","msg":"Multi threading initialized"}
{"t":{"$date":"2023-02-08T20:55:23.764+00:00"},"s":"F", "c":"CONTROL", "id":6384300, "ctx":"main","msg":"Writing fatal message","attr":{"message":"terminate() called. An exception is active; attempting to gather more information\n"}}
{"t":{"$date":"2023-02-08T20:55:23.764+00:00"},"s":"F", "c":"CONTROL", "id":6384300, "ctx":"main","msg":"Writing fatal message","attr":{"message":"std::exception::what(): Operation not permitted\nActual exception type: std::system_error\n\n"}}
{"t":{"$date":"2023-02-08T20:55:23.868+00:00"},"s":"I", "c":"CONTROL", "id":31380, "ctx":"main","msg":"BACKTRACE","attr":{"bt":{"backtrace":[{"a":"5568807B18D4","b":"55687B9D3000","o":"4DDE8D4","s":"_ZN5mongo18stack_trace_detail12_GLOBAL__N_119printStackTraceImplERKNS1_7OptionsEPNS_14StackTraceSinkE.constprop.362","C":"mongo::stack_trace_detail::(anonymous namespace)::printStackTraceImpl(mongo::stack_trace_detail::(anonymous namespace)::Options const&, mongo::StackTraceSink*) [clone .constprop.362]","s+":"1F4"},{"a":"5568807B3E19","b":"55687B9D3000","o":"4DE0E19","s":"_ZN5mongo15printStackTraceEv","C":"mongo::printStackTrace()","s+":"29"},{"a":"5568807AE167","b":"55687B9D3000","o":"4DDB167","s":"_ZN5mongo12_GLOBAL__N_111myTerminateEv","C":"mongo::(anonymous namespace)::myTerminate()","s+":"D7"},{"a":"556880938BF6","b":"55687B9D3000","o":"4F65BF6","s":"_ZN10__cxxabiv111__terminateEPFvvE","C":"__cxxabiv1::__terminate(void (*)())","s+":"6"},{"a":"556880938C31","b":"55687B9D3000","o":"4F65C31","s":"_ZSt9terminatev","C":"std::terminate()","s+":"11"},{"a":"556880938D6B","b":"55687B9D3000","o":"4F65D6B","s":"__cxa_throw","s+":"4B"},{"a":"55687D8E247B","b":"55687B9D3000","o":"1F0F47B","s":"_ZSt20__throw_system_errori.cold.24","C":"std::__throw_system_error(int) [clone .cold.24]","s+":"2F"},{"a":"556880954F69","b":"55687B9D3000","o":"4F81F69","s":"_ZNSt6thread15_M_start_threadESt10unique_ptrINS_6_StateESt14default_deleteIS1_EEPFvvE","C":"std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())","s+":"29"},{"a":"55687E87D07A","b":"55687B9D3000","o":"2EAA07A","s":"_ZN5mongo27startSignalProcessingThreadENS_13LogFileStatusE","C":"mongo::startSignalProcessingThread(mongo::LogFileStatus)","s+":"11A"},{"a":"55687DAF31EA","b":"55687B9D3000","o":"21201EA","s":"_ZN5mongo11mongod_mainEiPPc","C":"mongo::mongod_main(int, char**)","s+":"B8A"},{"a":"55687D8E31BE","b":"55687B9D3000","o":"1F101BE","s":"main","s+":"E"},{"a":"7F5E107A1D90","b":"7F5E10778000","o":"29D90","s":"__libc_init_first","s+":"90"},{"a":"7F5E107A1E40","b":"7F5E10778000","o":"29E40","s":"__libc_start_main","s+":"80"},{"a":"55687DAEDA95","b":"55687B9D3000","o":"211AA95","s":"_start","s+":"25"}],"processInfo":{"mongodbVersion":"6.0.4","gitVersion":"44ff59461c1353638a71e710f385a566bcd2f547","compiledModules":[],"uname":{"sysname":"Linux","release":"5.15.0-53-generic","version":"#59~20.04.1-Ubuntu SMP Thu Oct 20 15:10:22 UTC 2022","machine":"x86_64"},"somap":[{"b":"55687B9D3000","elfType":3,"buildId":"BCB8F6C3AD4ABF41C81882BAE25C6885C6266CC4"},{"b":"7F5E10778000","path":"/lib/x86_64-linux-gnu/libc.so.6","elfType":3,"buildId":"69389D485A9793DBE873F0EA2C93E02EFAA9AA3D"}]}}},"tags":[]}
{"t":{"$date":"2023-02-08T20:55:23.868+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"5568807B18D4","b":"55687B9D3000","o":"4DDE8D4","s":"_ZN5mongo18stack_trace_detail12_GLOBAL__N_119printStackTraceImplERKNS1_7OptionsEPNS_14StackTraceSinkE.constprop.362","C":"mongo::stack_trace_detail::(anonymous namespace)::printStackTraceImpl(mongo::stack_trace_detail::(anonymous namespace)::Options const&, mongo::StackTraceSink*) [clone .constprop.362]","s+":"1F4"}}}
{"t":{"$date":"2023-02-08T20:55:23.868+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"5568807B3E19","b":"55687B9D3000","o":"4DE0E19","s":"_ZN5mongo15printStackTraceEv","C":"mongo::printStackTrace()","s+":"29"}}}
{"t":{"$date":"2023-02-08T20:55:23.868+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"5568807AE167","b":"55687B9D3000","o":"4DDB167","s":"_ZN5mongo12_GLOBAL__N_111myTerminateEv","C":"mongo::(anonymous namespace)::myTerminate()","s+":"D7"}}}
{"t":{"$date":"2023-02-08T20:55:23.868+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"556880938BF6","b":"55687B9D3000","o":"4F65BF6","s":"_ZN10__cxxabiv111__terminateEPFvvE","C":"__cxxabiv1::__terminate(void (*)())","s+":"6"}}}
{"t":{"$date":"2023-02-08T20:55:23.869+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"556880938C31","b":"55687B9D3000","o":"4F65C31","s":"_ZSt9terminatev","C":"std::terminate()","s+":"11"}}}
{"t":{"$date":"2023-02-08T20:55:23.869+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"556880938D6B","b":"55687B9D3000","o":"4F65D6B","s":"__cxa_throw","s+":"4B"}}}
{"t":{"$date":"2023-02-08T20:55:23.869+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"55687D8E247B","b":"55687B9D3000","o":"1F0F47B","s":"_ZSt20__throw_system_errori.cold.24","C":"std::__throw_system_error(int) [clone .cold.24]","s+":"2F"}}}
{"t":{"$date":"2023-02-08T20:55:23.869+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"556880954F69","b":"55687B9D3000","o":"4F81F69","s":"_ZNSt6thread15_M_start_threadESt10unique_ptrINS_6_StateESt14default_deleteIS1_EEPFvvE","C":"std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())","s+":"29"}}}
{"t":{"$date":"2023-02-08T20:55:23.869+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"55687E87D07A","b":"55687B9D3000","o":"2EAA07A","s":"_ZN5mongo27startSignalProcessingThreadENS_13LogFileStatusE","C":"mongo::startSignalProcessingThread(mongo::LogFileStatus)","s+":"11A"}}}
{"t":{"$date":"2023-02-08T20:55:23.869+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"55687DAF31EA","b":"55687B9D3000","o":"21201EA","s":"_ZN5mongo11mongod_mainEiPPc","C":"mongo::mongod_main(int, char**)","s+":"B8A"}}}
{"t":{"$date":"2023-02-08T20:55:23.869+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"55687D8E31BE","b":"55687B9D3000","o":"1F101BE","s":"main","s+":"E"}}}
{"t":{"$date":"2023-02-08T20:55:23.869+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"7F5E107A1D90","b":"7F5E10778000","o":"29D90","s":"__libc_init_first","s+":"90"}}}
{"t":{"$date":"2023-02-08T20:55:23.869+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"7F5E107A1E40","b":"7F5E10778000","o":"29E40","s":"__libc_start_main","s+":"80"}}}
{"t":{"$date":"2023-02-08T20:55:23.869+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"55687DAEDA95","b":"55687B9D3000","o":"211AA95","s":"_start","s+":"25"}}}
{"t":{"$date":"2023-02-08T20:56:24.598+00:00"},"s":"I", "c":"NETWORK", "id":4915701, "ctx":"-","msg":"Initialized wire specification","attr":{"spec":{"incomingExternalClient":{"minWireVersion":0,"maxWireVersion":17},"incomingInternalClient":{"minWireVersion":0,"maxWireVersion":17},"outgoing":{"minWireVersion":6,"maxWireVersion":17},"isInternalClient":true}}}
{"t":{"$date":"2023-02-08T20:56:24.601+00:00"},"s":"I", "c":"CONTROL", "id":23285, "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2023-02-08T20:56:24.602+00:00"},"s":"I", "c":"NETWORK", "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
{"t":{"$date":"2023-02-08T20:56:24.604+00:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationDonorService","namespace":"config.tenantMigrationDonors"}}
{"t":{"$date":"2023-02-08T20:56:24.604+00:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationRecipientService","namespace":"config.tenantMigrationRecipients"}}
{"t":{"$date":"2023-02-08T20:56:24.604+00:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"ShardSplitDonorService","namespace":"config.tenantSplitDonors"}}
{"t":{"$date":"2023-02-08T20:56:24.604+00:00"},"s":"I", "c":"CONTROL", "id":5945603, "ctx":"main","msg":"Multi threading initialized"}
{"t":{"$date":"2023-02-08T20:56:24.605+00:00"},"s":"F", "c":"CONTROL", "id":6384300, "ctx":"main","msg":"Writing fatal message","attr":{"message":"terminate() called. An exception is active; attempting to gather more information\n"}}
{"t":{"$date":"2023-02-08T20:56:24.605+00:00"},"s":"F", "c":"CONTROL", "id":6384300, "ctx":"main","msg":"Writing fatal message","attr":{"message":"std::exception::what(): Operation not permitted\nActual exception type: std::system_error\n\n"}}
{"t":{"$date":"2023-02-08T20:56:24.704+00:00"},"s":"I", "c":"CONTROL", "id":31380, "ctx":"main","msg":"BACKTRACE","attr":{"bt":{"backtrace":[{"a":"56552EF1F8D4","b":"56552A141000","o":"4DDE8D4","s":"_ZN5mongo18stack_trace_detail12_GLOBAL__N_119printStackTraceImplERKNS1_7OptionsEPNS_14StackTraceSinkE.constprop.362","C":"mongo::stack_trace_detail::(anonymous namespace)::printStackTraceImpl(mongo::stack_trace_detail::(anonymous namespace)::Options const&, mongo::StackTraceSink*) [clone .constprop.362]","s+":"1F4"},{"a":"56552EF21E19","b":"56552A141000","o":"4DE0E19","s":"_ZN5mongo15printStackTraceEv","C":"mongo::printStackTrace()","s+":"29"},{"a":"56552EF1C167","b":"56552A141000","o":"4DDB167","s":"_ZN5mongo12_GLOBAL__N_111myTerminateEv","C":"mongo::(anonymous namespace)::myTerminate()","s+":"D7"},{"a":"56552F0A6BF6","b":"56552A141000","o":"4F65BF6","s":"_ZN10__cxxabiv111__terminateEPFvvE","C":"__cxxabiv1::__terminate(void (*)())","s+":"6"},{"a":"56552F0A6C31","b":"56552A141000","o":"4F65C31","s":"_ZSt9terminatev","C":"std::terminate()","s+":"11"},{"a":"56552F0A6D6B","b":"56552A141000","o":"4F65D6B","s":"__cxa_throw","s+":"4B"},{"a":"56552C05047B","b":"56552A141000","o":"1F0F47B","s":"_ZSt20__throw_system_errori.cold.24","C":"std::__throw_system_error(int) [clone .cold.24]","s+":"2F"},{"a":"56552F0C2F69","b":"56552A141000","o":"4F81F69","s":"_ZNSt6thread15_M_start_threadESt10unique_ptrINS_6_StateESt14default_deleteIS1_EEPFvvE","C":"std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())","s+":"29"},{"a":"56552CFEB07A","b":"56552A141000","o":"2EAA07A","s":"_ZN5mongo27startSignalProcessingThreadENS_13LogFileStatusE","C":"mongo::startSignalProcessingThread(mongo::LogFileStatus)","s+":"11A"},{"a":"56552C2611EA","b":"56552A141000","o":"21201EA","s":"_ZN5mongo11mongod_mainEiPPc","C":"mongo::mongod_main(int, char**)","s+":"B8A"},{"a":"56552C0511BE","b":"56552A141000","o":"1F101BE","s":"main","s+":"E"},{"a":"7F31AFA88D90","b":"7F31AFA5F000","o":"29D90","s":"__libc_init_first","s+":"90"},{"a":"7F31AFA88E40","b":"7F31AFA5F000","o":"29E40","s":"__libc_start_main","s+":"80"},{"a":"56552C25BA95","b":"56552A141000","o":"211AA95","s":"_start","s+":"25"}],"processInfo":{"mongodbVersion":"6.0.4","gitVersion":"44ff59461c1353638a71e710f385a566bcd2f547","compiledModules":[],"uname":{"sysname":"Linux","release":"5.15.0-53-generic","version":"#59~20.04.1-Ubuntu SMP Thu Oct 20 15:10:22 UTC 2022","machine":"x86_64"},"somap":[{"b":"56552A141000","elfType":3,"buildId":"BCB8F6C3AD4ABF41C81882BAE25C6885C6266CC4"},{"b":"7F31AFA5F000","path":"/lib/x86_64-linux-gnu/libc.so.6","elfType":3,"buildId":"69389D485A9793DBE873F0EA2C93E02EFAA9AA3D"}]}}},"tags":[]}
{"t":{"$date":"2023-02-08T20:56:24.704+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"56552EF1F8D4","b":"56552A141000","o":"4DDE8D4","s":"_ZN5mongo18stack_trace_detail12_GLOBAL__N_119printStackTraceImplERKNS1_7OptionsEPNS_14StackTraceSinkE.constprop.362","C":"mongo::stack_trace_detail::(anonymous namespace)::printStackTraceImpl(mongo::stack_trace_detail::(anonymous namespace)::Options const&, mongo::StackTraceSink*) [clone .constprop.362]","s+":"1F4"}}}
{"t":{"$date":"2023-02-08T20:56:24.704+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"56552EF21E19","b":"56552A141000","o":"4DE0E19","s":"_ZN5mongo15printStackTraceEv","C":"mongo::printStackTrace()","s+":"29"}}}
{"t":{"$date":"2023-02-08T20:56:24.704+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"56552EF1C167","b":"56552A141000","o":"4DDB167","s":"_ZN5mongo12_GLOBAL__N_111myTerminateEv","C":"mongo::(anonymous namespace)::myTerminate()","s+":"D7"}}}
{"t":{"$date":"2023-02-08T20:56:24.704+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"56552F0A6BF6","b":"56552A141000","o":"4F65BF6","s":"_ZN10__cxxabiv111__terminateEPFvvE","C":"__cxxabiv1::__terminate(void (*)())","s+":"6"}}}
{"t":{"$date":"2023-02-08T20:56:24.704+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"56552F0A6C31","b":"56552A141000","o":"4F65C31","s":"_ZSt9terminatev","C":"std::terminate()","s+":"11"}}}
{"t":{"$date":"2023-02-08T20:56:24.704+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"56552F0A6D6B","b":"56552A141000","o":"4F65D6B","s":"__cxa_throw","s+":"4B"}}}
{"t":{"$date":"2023-02-08T20:56:24.704+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"56552C05047B","b":"56552A141000","o":"1F0F47B","s":"_ZSt20__throw_system_errori.cold.24","C":"std::__throw_system_error(int) [clone .cold.24]","s+":"2F"}}}
{"t":{"$date":"2023-02-08T20:56:24.704+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"56552F0C2F69","b":"56552A141000","o":"4F81F69","s":"_ZNSt6thread15_M_start_threadESt10unique_ptrINS_6_StateESt14default_deleteIS1_EEPFvvE","C":"std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())","s+":"29"}}}
{"t":{"$date":"2023-02-08T20:56:24.704+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"56552CFEB07A","b":"56552A141000","o":"2EAA07A","s":"_ZN5mongo27startSignalProcessingThreadENS_13LogFileStatusE","C":"mongo::startSignalProcessingThread(mongo::LogFileStatus)","s+":"11A"}}}
{"t":{"$date":"2023-02-08T20:56:24.704+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"56552C2611EA","b":"56552A141000","o":"21201EA","s":"_ZN5mongo11mongod_mainEiPPc","C":"mongo::mongod_main(int, char**)","s+":"B8A"}}}
{"t":{"$date":"2023-02-08T20:56:24.704+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"56552C0511BE","b":"56552A141000","o":"1F101BE","s":"main","s+":"E"}}}
{"t":{"$date":"2023-02-08T20:56:24.704+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"7F31AFA88D90","b":"7F31AFA5F000","o":"29D90","s":"__libc_init_first","s+":"90"}}}
{"t":{"$date":"2023-02-08T20:56:24.704+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"7F31AFA88E40","b":"7F31AFA5F000","o":"29E40","s":"__libc_start_main","s+":"80"}}}
{"t":{"$date":"2023-02-08T20:56:24.704+00:00"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"56552C25BA95","b":"56552A141000","o":"211AA95","s":"_start","s+":"25"}}}
It has some error messages. Are they critical ?
- In docker-compose.yml I have defined :
mongodb:
container_name: MngProducts_mongodb
image: mongo:latest
volumes:
- ./data/db:/data/db
ports:
- 27017:27017
restart: always
- Next I check all services in my bash:
# service --status-all
[ - ] apache-htcacheclean
[ + ] apache2
[ ? ] hwclock.sh
[ - ] procps
[ - ] x11-common
and check apache2 package:
# dpkg -s apache2
Package: apache2
Status: install ok installed
Priority: optional
Section: httpd
Installed-Size: 622
...
/etc/init.d/apache2 9d22fb30358e61a6f190a0d09c5120bf
/etc/logrotate.d/apache2 ab347819cceccf236cfe769a13b89d2a
Description: Apache HTTP Server
The Apache HTTP Server Project's goal is to build a secure, efficient and
extensible HTTP server as standards-compliant open source software. The
result has long been the number one web server on the Internet.
.
Installing this package results in a full installation, including the
configuration files, init scripts and support scripts.
Homepage: https://httpd.apache.org/
But I do not find any mongo packages:
# dpkg -s mongo
dpkg-query: package 'mongo' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
# dpkg -s mongod
dpkg-query: package 'mongod' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
# dpkg -s mongodb
dpkg-query: package 'mongodb' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
and that is very strange as mongo was installed in docker installation process, but with some errors I mentioned above.
?
@PetroGromovo reading
...
PrimaryOnlyService","attr":{"service":"ShardSplitDonorService","namespace":"config.tenantSplitDonors"}}
{"t":{"$date":"2023-02-08T20:55:23.764+00:00"},"s":"I", "c":"CONTROL", "id":5945603, "ctx":"main","msg":"Multi threading initialized"}
{"t":{"$date":"2023-02-08T20:55:23.764+00:00"},"s":"F", "c":"CONTROL", "id":6384300, "ctx":"main","msg":"Writing fatal message","attr":{"message":"terminate() called. An exception is active; attempting to gather more information\n"}}
{"t":{"$date":"2023-02-08T20:55:23.764+00:00"},"s":"F", "c":"CONTROL", "id":6384300, "ctx":"main","msg":"Writing fatal message","attr":{"message":"std::exception::what(): Operation not permitted\nActual exception type: std::system_error\n\n"}}
...
it looks like a chown or chmod or permissions error on adding MongoDB. You did not use sudo or a user that is allowed to to install the package? Also sudo does not seem to be available once done. Normally you need to have sudo available , add user you run commands with to sudo list and then run the commands. Example:
....I had to add the user to the sudoers group. But the main reason was I'd forgotten to update the repositories cache, so apt-get couldn't find the sudo package. It's working now. Here's the completed code:
FROM ubuntu:12.04
RUN apt-get update && \
apt-get -y install sudo
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
USER docker
CMD /bin/bash
https://stackoverflow.com/a/25908200/460885
You can of course use a different user. But you need one in sudo group to run sudo commands. And.. you need sudo
NB Why did you not just run the official MongoDB image as a separate container?
@rhand I had a problem with installing mongo under docker at at branch https://stackoverflow.com/questions/75057581/add-mongo-in-my-docker-project-i-got-ref-error I got hints how to salve it.
Referenced official documents at https://repo.mongodb.org/apt/ubuntu has sudo it its command and I removed all sudo in my Dockerfile.yml scripts. Now following your instructions I modified my Dockerfile.yml :
FROM php:8.1.6-apache
RUN apt-get update && \
apt-get install --assume-yes --no-install-recommends --quiet \
curl \
wget \
systemd \
gnupg
// I install sudo package
RUN apt-get -y install sudo
// I use sudo just as on monogo docs
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
USER docker
CMD /bin/bash
RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
// I use sudo just as on mongo docs
RUN echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions \
&& install-php-extensions mongodb
But I got error :
Step 6/22 : CMD /bin/bash
---> Using cache
---> 11c06cad2a23
Step 7/22 : RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
---> Running in fcbb88c384c3
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
sudo: a password is required
ERROR: Service 'web' failed to build: The command '/bin/sh -c wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -' returned a non-zero code: 1
I tried to add “ -S ”, but with error again :
RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo -S apt-key add -
RUN echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo -S tee /etc/apt/sources.list.d/mongodb-org-6.0.list
But got :
---> 11c06cad2a23
Step 7/22 : RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo -S apt-key add -
---> Running in f1f9523c6500
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for docker: Sorry, try again.
[sudo] password for docker: Sorry, try again.
[sudo] password for docker: sudo: 3 incorrect password attempts
ERROR: Service 'web' failed to build: The command '/bin/sh -c wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo -S apt-key add -' returned a non-zero code: 1
How to set password ccorrectly? Actually I do not have any sudo password ...
@PetroGromovo What you could do is add a non root user with passwordless sudo
Here Visual Studio Code example I borrowed. Did add passwordless access via visudo before, but this is the way in a Docker file
ARG USERNAME=user-name-goes-here
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
#
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
# ********************************************************
# * Anything else you want to do like clean up goes here *
# ********************************************************
# [Optional] Set the default user. Omit if you want to keep the default as root.
USER $USERNAME
see https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user .
and then you can use that user to run sudo commands without password need. This does need to be added before all the commands run with your set user that needs sudo.
@rhand I try to follow these steps and remade Dockerfile.yml (I tried to set NOPASSWD option AFTER user docker was added) :
FROM php:8.1.6-apache
RUN apt-get update && \
apt-get install --assume-yes --no-install-recommends --quiet \
curl \
wget \
systemd \
gnupg
RUN apt-get -y install sudo
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
RUN chmod 0440 /etc/sudoers.d/$USERNAME
USER docker
CMD /bin/bash
RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo -S apt-key add -
RUN echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo -S tee /etc/apt/sources.list.d/mongodb-org-6.0.list
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
But I got error:
Step 1/23 : FROM php:8.1.6-apache
---> af944036d594
Step 2/23 : RUN apt-get update && apt-get install --assume-yes --no-install-recommends --quiet curl wget systemd gnupg
---> Using cache
---> 58852b92639b
Step 3/23 : RUN apt-get -y install sudo
---> Using cache
---> 4c16ddb28aa9
Step 4/23 : RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
---> Using cache
---> 8a3a3eaa2914
Step 5/23 : RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME RUN chmod 0440 /etc/sudoers.d/$USERNAME
---> Running in 129179e9e96d
/bin/sh: 1: cannot create /etc/sudoers.d/: Is a directory
ERROR: Service 'web' failed to build: The command '/bin/sh -c echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME RUN chmod 0440 /etc/sudoers.d/$USERNAME' returned a non-zero code: 2
Which syntax is correct ?
@PetroGromovo where is $USERNAME set? See https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user . Perhaps after added user docker to shudders group you can update it and allow no password usage, but you cannot throw in docker and then $USERNAME after. Value has to be set.
@rhand 1) I try do add "docker-user" user BEFORE useradd command in Dockerfile.yml :
FROM php:8.1.6-apache
RUN apt-get update && \
apt-get install --assume-yes --no-install-recommends --quiet \
curl \
wget \
systemd \
gnupg
RUN apt-get -y install sudo
RUN ARG USERNAME=docker-user
RUN ARG USER_UID=1000
RUN ARG USER_GID=$USER_UID
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
RUN echo docker ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
RUN chmod 0440 /etc/sudoers.d/$USERNAME
USER docker
CMD /bin/bash
RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo -S apt-key add -
But I got an error :
Step 3/26 : RUN apt-get -y install sudo
---> Using cache
---> 4c16ddb28aa9
Step 4/26 : RUN ARG USERNAME=docker-user
---> Running in 207f739ea918
/bin/sh: 1: ARG: not found
ERROR: Service 'web' failed to build: The command '/bin/sh -c ARG USERNAME=docker-user' returned a non-zero code: 127
- I try without RUN before "ARG USERNAME=docker-user" :
FROM php:8.1.6-apache
RUN apt-get update && \
apt-get install --assume-yes --no-install-recommends --quiet \
curl \
wget \
systemd \
gnupg
RUN apt-get -y install sudo
ARG USERNAME=docker-user
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
RUN echo docker ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
RUN chmod 0440 /etc/sudoers.d/$USERNAME
USER docker
CMD /bin/bash
RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo -S apt-key add -
RUN echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo -S tee /etc/apt/sources.list.d/mongodb-org-6.0.list
But I got prompt to enter password. I tried to enter "1" :
Removing intermediate container 8b9f8518c5ab
---> 4b54f32e2599
Step 10/26 : CMD /bin/bash
---> Running in a7b5e6cb0807
Removing intermediate container a7b5e6cb0807
---> 4cca53fc43bd
Step 11/26 : RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo -S apt-key add -
---> Running in c9ccefe2c5ab
/etc/sudoers.d/docker-user:1:32: syntax error
docker ALL=(root) NOPASSWD:ALL RUN chmod 0440 /etc/sudoers.d/docker-user
^~~
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for docker: Sorry, try again.
[sudo] password for docker: Sorry, try again.
[sudo] password for docker: 1
sudo: 3 incorrect password attempts
ERROR: Service 'web' failed to build: The command '/bin/sh -c wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo -S apt-key add -' returned a non-zero code: 1
$ 1
1: command not found
How can I avoid this prompt to enter password ?
To set up the non root user, add it to the proper groups and use sudo use the example properly and use the user for all commands. That means to use sudo after we set newly created user docker-user Do add missing PHP parts and other parts I missed.
FROM php:8.1.6-apache
# ********************************************************
# * Add non root user *
# ********************************************************
ARG USERNAME=docker-user
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
#
# Add sudo support.
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
# Set the default user. Omit if you want to keep the default as root.
USER $USERNAME
# Not sure if needed but kept for now
CMD /bin/bash
# ******************************************************
# * Run updates and install some basics. sudo used
# * as we run as docker-user without need for pasword
# ******************************************************
RUN sudo apt-get update && \
sudo apt-get install --assume-yes --no-install-recommends --quiet \
curl \
wget \
systemd \
gnupg
# ********************************************************
# * Add PHP parts
# * make sure we run using sudo!
# ********************************************************
# ********************************************************
# * Add MongoDB *
# ********************************************************
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
@rhand Thank you!
Following your hints I modified docker file:
FROM php:8.1.6-apache
# ********************************************************
# * Add non root user *
# ********************************************************
ARG USERNAME=docker-user
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
#
# Add sudo support.
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
# chmod must be run under root, so run it before USER $USERNAME
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN sudo chmod +x /usr/local/bin/install-php-extensions \
&& install-php-extensions mongodb
RUN sudo chmod +x /var/lib/apt/lists/
# Set the default user. Omit if you want to keep the default as root.
USER $USERNAME
# Not sure if needed but kept for now
CMD /bin/bash
# ******************************************************
# * Run updates and install some basics. sudo used
# * as we run as docker-user without need for pasword
# ******************************************************
RUN sudo apt-get update && \
sudo apt-get install --assume-yes --no-install-recommends --quiet \
curl \
wget \
systemd \
gnupg
RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo -S apt-key add -
# ********************************************************
# * Add PHP parts
# * make sure we run using sudo!
# ********************************************************
# ********************************************************
# * Add MongoDB *
# ********************************************************
RUN echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
RUN sudo apt-get update
RUN sudo apt-get install -y mongodb-org
RUN sudo chmod +x /var/lib/apt/lists/lock
RUN apt-get update && \
apt-get install --assume-yes --no-install-recommends --quiet \
python \
apt-transport-https \
libfreetype6-dev \
libwebp-dev \
libjpeg62-turbo-dev \
libpng-dev \
libzip-dev \
nano \
mc \
git-core \
libmagickwand-dev \
libsodium-dev \
build-essential \
libnotify-bin \
openssl \
libssl-dev \
libgmp-dev \
libldap2-dev \
netcat \
locate \
&& git clone https://github.com/nodejs/node.git && \
cd node \
&& git checkout v14.18.0 \
&& ./configure \
&& make \
&& make install
RUN apt-get install -y mongodb-org
RUN pecl install imagick \
&& docker-php-ext-enable imagick
RUN npm install cross-env
RUN npm install -g yarn
RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp --with-jpeg
RUN docker-php-ext-install gd
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install pdo zip gmp bcmath pcntl ldap sysvmsg exif \
&& a2enmod rewrite
RUN apt-get install -y grep mlocate
RUN docker-php-ext-install ldap sodium
COPY virtualhost.conf /etc/apache2/sites-enabled/000-default.conf
I got next error :
Step 16/28 : RUN sudo chmod +x /var/lib/apt/lists/lock
---> Running in a9a1d559467e
Removing intermediate container a9a1d559467e
---> 6426d08149b9
Step 17/28 : RUN apt-get update && apt-get install --assume-yes --no-install-recommends --quiet python apt-transport-https libfreetype6-dev libwebp-dev libjpeg62-turbo-dev libpng-dev libzip-dev nano mc git-core libmagickwand-dev libsodium-dev build-essential libnotify-bin openssl libssl-dev libgmp-dev libldap2-dev netcat locate && git clone https://github.com/nodejs/node.git && cd node && git checkout v14.18.0 && ./configure && make && make install
---> Running in 98235a133324
Reading package lists...
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
ERROR: Service 'web' failed to build: The command '/bin/sh -c apt-get update && apt-get install --assume-yes --no-install-recommends --quiet python apt-transport-https libfreetype6-dev libwebp-dev libjpeg62-turbo-dev libpng-dev libzip-dev nano mc git-core libmagickwand-dev libsodium-dev build-essential libnotify-bin openssl libssl-dev libgmp-dev libldap2-dev netcat locate && git clone https://github.com/nodejs/node.git && cd node && git checkout v14.18.0 && ./configure && make && make install' returned a non-zero code: 100
I suppose subdirectory "/var/lib/apt/lists/lock" is created during installation at does not exists at start of the script. So I added command
RUN sudo chmod +x /var/lib/apt/lists/lock
before command
RUN apt-get update && \
But I got the same error anyway...
How to fix it?
I tried to fix it with adding file :
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN sudo chmod +x /usr/local/bin/install-php-extensions \
&& install-php-extensions mongodb
RUN sudo chmod +x /var/lib/apt/lists/
RUN sudo touch /var/lib/apt/lists/lock
RUN sudo chmod +x /var/lib/apt/lists/lock
But I got error anyway :
git-core libmagickwand-dev libsodium-dev build-essential libnotify-bin openssl libssl-dev libgmp-dev libldap2-dev netcat locate && git clone https://github.com/nodejs/node.git && cd node
&& git checkout v14.18.0 && ./configure && make && make install
---> Running in d7b025f4d400
Reading package lists...
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
?
@rhand Dockerfile.yml is:
FROM php:8.1.6-apache
# ********************************************************
# * Add non root user *
# ********************************************************
ARG USERNAME=docker-user
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
#
# Add sudo support.
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
# chmod must be run under root, so run it before USER $USERNAME
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN sudo chmod +x /usr/local/bin/install-php-extensions \
&& install-php-extensions mongodb
RUN sudo chmod +x /var/lib/apt/lists/
RUN sudo touch /var/lib/apt/lists/lock
RUN sudo chmod +x /var/lib/apt/lists/lock
# RUN sudo chmod 777 /var/lib/apt/lists/lock
# RUN sudo chmod +x /var/lib/apt/lists/lock
# Set the default user. Omit if you want to keep the default as root.
USER $USERNAME
# Not sure if needed but kept for now
CMD /bin/bash
# ******************************************************
# * Run updates and install some basics. sudo used
# * as we run as docker-user without need for pasword
# ******************************************************
RUN sudo apt-get update && \
sudo apt-get install --assume-yes --no-install-recommends --quiet \
curl \
wget \
systemd \
gnupg
RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo -S apt-key add -
# ********************************************************
# * Add PHP parts
# * make sure we run using sudo!
# ********************************************************
# ********************************************************
# * Add MongoDB *
# ********************************************************
RUN echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
RUN sudo apt-get update
RUN sudo apt-get install -y mongodb-org
RUN apt-get update && \
apt-get install --assume-yes --no-install-recommends --quiet \
python \
apt-transport-https \
libfreetype6-dev \
libwebp-dev \
libjpeg62-turbo-dev \
libpng-dev \
libzip-dev \
nano \
mc \
git-core \
libmagickwand-dev \
libsodium-dev \
build-essential \
libnotify-bin \
openssl \
libssl-dev \
libgmp-dev \
libldap2-dev \
netcat \
locate \
&& git clone https://github.com/nodejs/node.git && \
cd node \
&& git checkout v14.18.0 \
&& ./configure \
&& make \
&& make install
RUN apt-get install -y mongodb-org
RUN pecl install imagick \
&& docker-php-ext-enable imagick
RUN npm install cross-env
RUN npm install -g yarn
RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp --with-jpeg
RUN docker-php-ext-install gd
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install pdo zip gmp bcmath pcntl ldap sysvmsg exif \
&& a2enmod rewrite
RUN apt-get install -y grep mlocate
RUN docker-php-ext-install ldap sodium
COPY virtualhost.conf /etc/apache2/sites-enabled/000-default.conf
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
Was this command run as root? Seems RUN sudo chmod +x /var/lib/apt/lists/lock is run by root before setting new user. And then ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ dies as it cannot work with lock file.
Check /var/lib/apt/lists/lock for group and user rights using ls -a /var/lib/apt/lists/lock and let me know.
@rhand where have I to run ls -a /var/lib/apt/lists/lock
command ? In my hosting kubuntu 20.04? Inside of docker script? But in which way ?
@PetroGromovo Inside the running container. Assume though the script does not fully run its course you can enter the container user docker exec it container_id bash. Container ids of running containers can be viewed with docker ps
Please or to participate in this conversation.