Lightest docker image to run python programs [closed] - python-3.x

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
The only requirement is to be able to run python 3 command , i won't be installing additional packages on it. I have used alpine before and I have seen python slim , are those my best options ?
Also would appreciate of you can point out similar images for other programming languages
What I am trying to build is a simple service to which the user sends his code + input and the service executes it on respective containers(pods) running on the cluster and returns the output

You could use the alpine package because it is light and secure focused, and then you can go through the services and applications, and decide if these are not needed and remove them. Afterwards you can create another Docker image from this container.
I found a webpage which helps with efficiency of a build, by using the Docker cache more effectively, if this helps,
https://vsupalov.com/speed-up-python-docker-image-build/
The Problem
Your Dockerfile probably contains something like this:
ADD code /app # executed on every small change
RUN pip install -r /app/requirements.txt
# and here we go again...
You’re adding your project code (Flask or Django project?) after installing the necessary libraries and setting up a virtual environment. Then, you’re running pip to install the exact versions of every Python dependency needed for the project in a “requirements.txt” file.
You’re not using the Docker cache as well as you could. The good news is: there’s a simple way to fix that.
Use The Docker Cache
You can prevent the perpetual re-execution of the dependency-installation step if there were not actual changes to the stuff you’re using. There’s no tricky volume mounting or multi-stage build kung-fu needed.
The ADD directive only needs to run if the referenced file changed since the last time it was executed. If it did, every single build step needs to run again, but if it’s the same you can just use a version from the Docker cache and skip to the next one.
If you add the requirements.txt file before your other code, and run the pip install step right after it, both will only be executed if the file changes. Not on every build.
ADD code/requirements.txt /app/requirements.txt
RUN pip install -r /app/requirements.txt
# the steps above only depend on the requirements.txt file!
ADD code /app
This way, you can skip the expensive operation if nothing changed and reuse a cached state. You Docker image build will be faster in most cases. Once that’s not enough anymore, there are more elaborate ways to improve on the process.

Related

Build Docker image with a future view of RPM upgrade [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
My aim is to build a docker image for my application, the core part of the application is installed through RPM during the image build.
Suppose I've built my docker image with 'application-version-1.rpm' file and a container is running with this image. After one or two month back developers released a new rpm with patch 'application-version-2.rpm', I need to install/upgrade this rpm file inside the running container. as this container is running on production, how can I update my image with existing data and with the newly released rpm file. Any Idea on this.
Note: I need to stop an application service to install/upgrade the new rpm file. The Entrypoint in my docker image is the application service. So if I stop the application service, it will stop the container.
You basically never do software updates inside a running Docker container. Instead, you build a new Docker image with the new software installed, stop the existing container, and start a new one with the new image.
docker run --name myapp ... myapp:1
# Time passes
docker build --no-cache -t myapp:2 .
docker stop myapp
docker rm myapp
docker run --name myapp ... myapp:2
Deleting containers like this is extremely routine, so if there's any data you care about you need to make sure it's stored outside the container using a docker run -v option.
If you're using Docker Compose as an orchestrator you might be able to docker-compose stop your existing container, then docker-compose up --build again; or you can rebuild the image manually with docker build and change the image: line in your docker-compose.yml file. If you're using a Kubernetes Deployment, changing the image: in its pod spec will actually cause it to first start a new container (pod) then delete the old one, for a zero-downtime update.

Is it alright to install Python on D drive? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I am embarking on the journey to learn Python and decided to start with Python 3.7.3
However, I had a couple of questions before I install python on my computer.
My C drive is an M.2 SSD with only about 60 GBs of space left in it. I do not know how much space my python projects would take as I go on about educating myself in the language. Hence I wanted to know whether installing Python and an IDE like PyCharm in D drive would work. Would it affect where pip installs Modules and Libraries?
Python does not care where it gets installed as long as you know where it is at and preferably is in your system path.
Might I suggest checking out https://pythonprogramming.net
EDIT: Below will print the location of your site packages (aka. the things you pip install)
import site
print(site.getsitepackages())
One last thing... My suggestion is just install Python to its default.
THEN! pip install virtualenv
NEXT cd into a directory on your other drive
mkdir my-python-code
cd my-python-code
virtualenv --name my-python-env
Then just use that virtual environment. This does two things for you it uses your other drive like you want. But it also gets you using Virtual Environments early on which is a good habit to be in.
This might be useful for getting started with virtualenv.

What Jail/Chroot/Sandbox-like mechanisms are available on OpenBSD? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I have recently started using OpenBSD. And I want to create easy fire-and-forget containers/VM or something es (it should be used as a Sandbox).
The user can upload his source code (C++/Java/Perl), it will be compiled on the Server (OpenBSD), if this was successful, it should execute this File and then return the result to the Web page.
How can I provide this in OpenBSD?
Also, should I use chroot, since 'jail' will be removed in 6.0? Or are there other possibilities to create a "sandbox" in OpenBSD?
Currently OpenBSD doesn't support any "chroot on steroid" mechanism. In the past, same jail feature (named sysjail) was in ports, but removed in 2007 because it was not easy to maintain and pretty insecure. You can find more information about it on stackexchange and with your search engine.
Historically, OpenBSD only support chroot(8) and work exactly like other system:
create an alternative root with userland on it
# create your target chroot
target="/tmp/chroot"
mkdir ${target}
# now build and install your userland
cd /usr
cvs -qz3 -d${repository} co src -r${openbsd_release}
cd /usr/src
make obj && make && make install DESTDIR=${target}
start your daemon or your soft in it
# in root
chroot /tmp/chroot
# run your daemon here
# note: you need to init also dev directory
# and, eventually, customize /etc/fstab
# /tmp is currently not allowed to have dev on it
# please see fstab(5) man page
Lot of software in base support chroot feature, openntpd, openssh, httpd and many others are configured by default in isolated directory.
Now, since OpenBSD 5.9, you can use vmm(4) hypervisor and vmctl(8) in base. You can start your vmd daemon and create isolated container like any other hypervisor (bhyve, xen or kvm).
# from openbsd vmctl man page example
vmctl create disk.img -s 4.5G
vmctl start "myvm" -m 512M -i 1 -d disk.img -k /bsd
vmctl stop 1
You can also use another approach based on software in ports, qemu work pretty well but have poor performance on OpenBSD, due to lake of kernel acceleration support and in parts because of filesystem structure.
Now, concerning your main issue (offer a way of remote compiling source code), I guess the better idea is to truly isolate your code from main system, and using something like vmctl or qemu could be the good answer. Perhaps qemu would be the better, because you can use standard user to execute it, without kernel feature and with lot of network features, but compilation would be really slow.
Check out pledge and unveil
You can use pledge for restricting system calls and unveil for hiding the directories

Completely uninstall openldap from Redhat Linux server [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I have performed the following steps to install OpenLdap on my Redhat Linux Server:
1. untar the tar file
2. ./configure <--this ran successfully without error
3. make depend
4. make
5. make test <-- couldn't find any error
6. make install
7. started slapd: /usr/local/sbin/slapd
But the service is not starting. I don't see any slapd process in the ps -lef | grep slapd output. Also I see this, when i run : ldapsearch -x -b '' -s base '(objectclass=*)' namingContexts
ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
What could be the error and also How can I completely uninstall OPENLDAP
There are two questions here:
What could be the error?
It's possible that you haven't appropriately configured slapd. There are probably errors in your syslog (/var/log/messages) that will help you diagnose problems. You can also run slapd in debugging mode (slapd -d none) to see errors displayed on your terminal.
How can I completely uninstall OpenLDAP?
That's a little tricky, since you (a) elected to install it from source rather than using an existing package and (b) you didn't install it into a dedicated directory. To completely uninstall it, you would have to pay close attention to what files are installed by running make install and then remove them.
However, there's no harm in leaving the files installed on your system as long as you're not using them. You can remove anything that was installed into /usr/local/bin or /usr/local/sbin if you want to prevent them from conflicting with versions of those commands installed via system packages.
If OpenLDAP is the only thing you've installed in /usr/local you can just remove any files below that directory.
Generally, if you can use the pre-packaged versions of software available in your Linux distribution your life will be easier. For example, if you were to install the RedHat openldap-servers package, you would have a default configuration that would allow slapd to start and run correctly.
To uninstall. look through either the log output from the configure command, or type "configure --help" to see a list of directories that things are installed in by default. Most likely it populated files into /usr/local/bin, /usr/local/lib, and so forth, so you'll need to into those directories and remove the files by hand.

Linux console: git command not found on x64 Cent OS [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I have a completely fresh install of 64 Bit Cent OS 5.7, this is in VirtualBox on top of 64-bit XP.
I'm trying to install SSU.
Problem: The command 'git' was not found. See "code" below please.
Have tried looking this up: /usr/local/git/ does not exist: git: command not found (on OS X 10.5)
I don't care about source code: I just want git to work so SSU will install so I can try to access the bank on what seems like a huge whim.
I am signed in to Gnome as root and seem to be able to access my computer normally without being harassed about passwords excessively and can create or edit files.
[root#localhost ~]# $ git clone https://github.com/wesabe/ssu
bash: $: command not found
Concerns
Unfortunately every single time I ask these kinds of questions and don't make clarifications I end up having to make those clarifications. So...
No negativity or rudeness intended what-so-ever: if the answer involves editing a text file or copy-and-paste actions please tell me the locations to do so in the file manager instead of console commands. I'm perfectly okay copying and pasting console commands for things that really should be done in the console though.
Note: there appear to be numerous "git" commands and numerous "ssu" commands. I do NOT know the difference between them and would really prefer someone who has solid expertise to answer so that I nor others end up accidentally trashing our copies of Linux as it's been very difficult to get anything to work and stay working thus extending my personal stay with XP.
I will be more than happy to both accept an answer and thumbs it up should it be helpful.
I would first try installing git. As root:
yum install git
According to here,
yum install git-core
If that doesn't work you could add the EPEL source. There are also RPMs for git.

Resources