I'm new to Docker and I need to make a docker container for PHP + Apache on linux system from my own dockerfile. I see some dockerfile example that you can use apt-get to install php, which makes good sense for ubuntu or debian based linux system. but I later need to use this dockerfile on a Amazon linux which is Redhat based. Shall I change everything to yum in the dockerfile in order to make it working?


Your dockerfile needs to use commands that run inside the container. If the image is based on Debian/Ubuntu, you will use apt-get, but if the image is based on RHEL, you will use yum. The base OS is not important for this. So, if your current dockerfile is based on a debian derivative, you should be able to run it unchanged even in a RHEL based docker host.

Note that it's absolutely possible to run a Debian based container on a RHEL base system and vice versa.

  • 2
    He said Amazon Linux, which was forked long ago from CentOS 5 and has diverged from all other distributions since then, sufficiently that they are no longer cross-compatible. You can run yum but don't expect RPMs for RHEL to work on it. – Michael Hampton Dec 20 '16 at 9:32
  • Today I learned ☝︎ – Chopper3 Dec 20 '16 at 10:19
  • 1
    This was new for me as well, I always understood Amazon Linux as Yet Another RHEL Clone(tm). Anyway, if Docker runs on Amazon Linux (no idea if it does), it should still mean that if your Docker container is Debian based, you will use RUN apt-get .... and RUN yum ... for RHEL-based containers in your Dockerfile. – Sven Dec 20 '16 at 10:27
  • It's always worth noting that, being the kernel used within the container the same kernel the host OS uses, there might be corner cases where things don't work as expected if there's a mismatch between the expected behaviour of syscalls within the container and the host, e.g. an image of an old OS (with old packages); see also this extreme corner case – dawud Dec 20 '16 at 12:48
  • @dawud: Debian Hamm in Docker!? I'm actually quite impressed that this works at all. – Sven Dec 20 '16 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.