Are official docker images cross-platform compatible? - docker

What I mean is if I can run for example the official docker image DEBIAN and on top of that
run the official docker image NGINX with both same supported architecture e.g. Linux x86-64?
Will it work like I would install NGINX package for DEBIAN operating systems in non-docker way?
Because I'm learning docker and I've came across that NGINX was build and run from official NGINX repository for DEBIAN OS on top of the official docker image DEBIAN?
Is that a clue that docker images are not cross-platform compatible?
I've also came across this helpful question.

If by cross-platform you mean whether a docker image built on an x86_64 machine will run on a ppcle64 machine, then the answer is no (there are ways around it by using an emulator, but generally speaking the answer is no).
If you mean, whether an Ubuntu container can be run on a Debian host, then yes (provided host kernel version is compatible, which it will be, since you were able to install docker).
As for the question of why NGINX official image is Debian, the developers might have their own reasons. In fact, the official repo has Alpine flavour image as well. You can modify the Dockerfile to use Ubuntu image, make the necessary modifications (such as the ubuntu version of the installer) and build it on a Debian host. It will produce an Ubuntu image which will run an Ubuntu container on any Linux, Unix, MacOS or Windows (using Linux VM) . You can build that Dockerfile as is on an Ubuntu host and it will create the same nginx:latest image as you would download from dockerhub. This can be verified using the checksum.

Related

Does a docker image build on MacOS can be deployed to another OS like Linux?

I just got started with docker. To my understanding, docker container runs a discrete process on the host machine and shares system resources of host machine too to that process, and as we know, codes building for Linux may not able to run on MacOS, and vice versa. My question is: can a docker image built on an OS platform can be deployed to another OS, like MacOS to Linux, or Ubuntu to CentOS?
If the question is NO, how come it only has one official mysql image on docker repositories, but not multiple like for Mac, for Ubuntu, for RHEL?
Docker on mac works by creating a linux virtual machine. So a docker image built on Mac is in fact built on a linux virtual machine and can be freely exchanged with most other docker systems - including most docker on windows.
There is a windows version of dockers that is not linux based. Those images are not interchangeable.
In fact, the docker built from any linux-based image can be run (w/o VM as an additional layer) on any linux distribution that has the same OS kernel.
It means docker built from e.g. SuSE image can be then run on Fedora/Ubuntu/Debian/etc... w/o any restrictions.
Short form - yes it can, but i think it will depend on the setup - notably user/group in - docker-compose file.
Recently i had some issues with work docker-compose files being setup without a user specified, these work ok when building on a mac as had an app user, but when run on my linux machine the user defaulted to root and thus the build was not successful. So it depends on the quality of the config.
Docker images are platform agnostic. The first thing a Dockerfile declares is what base image it pulls from, and that should determine the operating system under which the containers will run.
Using the MySQL 8 Dockerfile as an example:
https://github.com/docker-library/mysql/blob/223f0be1213bbd8647b841243a3114e8b34022f4/8.0/Dockerfile
FROM debian:stretch-slim
This means the image, and thus any containers started from it, will be based on Debian Linux...even if the host machine is MacOS.

Docker image from Ubuntu 16.04 to CentOS 6.9

I am interested in creating a Docker image from Ubuntu 16.04 (Kernel 4.15.0-29-generic) to be run on a CentOS 6.9 (Kernel 2.6.32-696.30.1.el6.x86_64).
Are they compatible to run smoothly?
Thank you for your help!
CentOS 6 will not run any version of Docker "smoothly"; the last Docker version that even has a build for CentOS 6 is very old and even then there are kernel compatibility issues. I'd update your host to something newer.
Once you get past that, there aren't usually any substantial issue running different Linux distributions between the host and in containers. You'll routinely see hosts running very minimal distributions (for instance there isn't much in the boot2docker distribution that Docker Machine VMs use), and images frequently run very light-weight distributions such as Alpine or even have nothing resembling a "Linux distribution" at all.

Windows based couchbase image for docker

Is windows based image for "couchbase" available to install with docker? or any way around so that couchbase can be installed with docker in windows container.
The images are based always on Linux. You know an image is based on other image recursively till reach a base image like ubuntu, debian or whatever. Anyway, it is suppossed they are not related to the host O.S. They can be run on a Docker using a Windows host, Linux host or OSX host in the same way. On Windows or OSX you can install Docker to run container based on Linux images, there is no problem about that.
Depending of the use of the container, if it needs some hardware to be useful (like wireless cards or something like that), then the host is important because there are drivers and kernel directly involved. But usually, any image can be used to run containers independently of the Docker host.
As of today (2017-10-02), I don't think there is an official Couchbase Docker image for Windows container. Their Dockerfile shows that their images are built off of Ubuntu.
You can try setting everything up manually by following the steps below. (Note that installing via Chocolatey is just a convenience. You can choose another method.)
Get Windows Server Core image.
host> docker pull microsoft/windowsservercore
Start the container in interactive mode
host> docker run -it --name couchbase-on-windows microsoft/windowsservercore
Switch to PowerShell
container-cmd> PowerShell
Install Chocolatey
container-ps> Set-ExecutionPolicy Bypass; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Install Couchbase. (The version on chocolatey might be a bit behind the latest.)
container-ps> choco install couchbase-server-community
If all this works to your liking, then you can create a Dockerfile to make your own Docker image. You can see what this person did to create an image for Redis on Windows. Here's his Dockerfile.

running docker remotely on openvz

I have a openvz vps which is centos 7 but with a 2.6 kernel. I know this is not compatible with docker. I have another KVM vps which has docker on it. Is there anyway to access docker in KVM remotely using my openvz vps? Basically I want my openvz box to be my dev machine and Ill deploy to KVM docker. What would be an ideal setup above?
You say the host has a 2.6.x kernel, but that covers a couple different releases. I have made docker work in an openvz VPS on a host with 2.6.32 kernel (derived from RedHat el6) but it would probably not work for kernels 2.6.18 or 2.6.9 (you really should upgrade if you have 2.6.9 as that is based on RedHat el4 kernel, 2.6.18 should be fine until 3/2017). You can find instructions to make it work with a compatible kernel at the openvz wiki. WARNING: docker does not perform very well in this configuration (2.6.32 kernel, CentOS 7 VPS) as you do not get any of the fancy filesystem layering functionality since you are forced to use the "vfs" storage engine. Each layer of the docker container will be a full copy of its underlying filesystem, grossly ballooning disk usage for images with lots of layers.
If you are not running a docker compatible kernel, you would not be able to run any of the docker tools at all, so your options are limited. If you still want to develop docker containers on your VPS to move to your KVM, you could use chroot and yum/rpm to construct your container and make a ${docker_image}.tgz file on your VPS and then copy that to your KVM and import into docker.
Hope that helps.

Docker: Mixing distros - any disadvantage?

I am running a RHEL 7 server and I am deploying containers using docker. Since you need to have RHEL servers and containers registered with RHN, I am now thinking of using centos7 docker images rather than RHEL7 ones, to avoid the RHN hassles.
Can anybody see any downside to doing it this way?
Since the kernel is the same you can use any distro available: Why docker has ability to run different linux distribution?.
For example many projects are moving to Alpine Linux because it give you the ability to build very small images: see Docker Official Images are Moving to Alpine Linux.

Resources