skip to Main Content

I’m new learner into docker so forgive me if my question sounds silly.

In my latest question I had 2 FROM statements inside my dockerfile.

I have a python script which one customer asked me to run into separate docker image and not his OS (for security and compatibility reasons).

For my python script to run I need few things:

  • Google Chrome – I know how to install it manually on docker image
  • Python3

For each one I need the latest stable version (for example python 3.10.6) – really important.

Which docker image should I use, I found multiple images like:

FROM ubuntu:latest
FROM python:latest

If there is a performance difference then this is a plus to me.

3

Answers


  1. I m not sure if I well understood your question, but I think you want to have 1 docker with Google Chrome, Google Driver and python3 on the same docker right ?

    I didn’t know about Google Chrome on a docker, just about selenium web driver, but that won’t change the answer.

    If you know how to install this with command lines, you cant make a FROM ubuntu:latest and then add lines like : RUN apt-get update;apt-get install "your_package". (the apt-get update is very important if you want to install things).

    Your Dockerfile can look like this:

    FROM ubutu:latest
    
    RUN apt-get update;apt-get install iputils-ping -y; #(that s an example)
    

    Then you ll just have to install python like on your computer with the command apt install python3.10 for example.

    Hope I helped you 😉

    Login or Signup to reply.
  2. You started in the right direction. But a few things that will help.

    1. Don’t use the tag "latest" for anything other than testing on your local machine. Latest, implies the "latest" image from the registry but isn’t guaranteed to be any single version. Instead pick a version tag and stick to that or update it if you need something newer, AVOID latest.

    2. Install specific versions with your package manager as well, for pretty much the same reasons as above.

    In my time helping people with container issues at cycle.io, I’ve seen using latest tags wreak havoc on programs that accidentally use a "newer" image than expected.

    Good luck, hope this helps.

    Login or Signup to reply.
  3. The short answer here is that it really depends on a few factors and you’re asking multiple questions, but to try and answer this simply:

    If you care about the python version being exact and don’t really care about the OS, other than it being of common use, start with a slim python image (they use debian as the base OS): docker pull python:3.10.6-slim. If you care about which debian OS, you can choose from those as well. Just swap the tag to whatever you’d like from this list: https://hub.docker.com/_/python/tags?page=1&name=3.10.6-

    At the end of the day, if all you need is python, a chrome driver, and a few extra doo-dads, the OS doesn’t really matter, so go with an image (like python) that you know has a base of what you need. Then, you can build up the other packages by adding those in, along with a few packages you may need along the way (i.e. you might need to install curl/wget to pull in a specific version of chrome/chrome driver).

    @shookzy’s advice to not use latest tags is sound. Use a tag that you know will give you the OS, size, and packages you want as the base image.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search