69

I am a Java developer. We use Weblogic to host our applications. I have been told to look into replacing weblogic with an opensource alternative. We are planning use with SpringBoot. We are also looking at Docker/Cloud Foundry. However Docker/Cloud Foundry is new territory for me.

  1. Can someone please tell me the difference between Cloud Foundry and Docker?
  2. If we use Docker but not Cloud foundry, what are we missing out on?
  3. If we use Cloud Foundry but not Docker, what are we missing out on?

Thank you for your help.

A B
  • 2,013
  • 2
  • 21
  • 22
James
  • 836
  • 1
  • 7
  • 5
  • It would be more correct to compare Docker with [Warden](https://github.com/cloudfoundry/warden) (used under the hood of CF). – D-side Jun 13 '15 at 15:41
  • http://heidloff.net/nh/home.nsf/article.xsp?id=20.02.2015092308NHEBUJ.htm – satks Jun 13 '15 at 16:56
  • 1
    You can't compare a PaaS (Platform as a service) with a Container technogloy. A container technology is only a very small part of Cloud Foundry. – Sybil Jun 18 '15 at 13:02

1 Answers1

141

Docker is a technology for creating and running Linux "containers." In some sense, you can think of these as lightweight VMs. A docker container for SpringBoot app will consist of a docker image, which will basically contain a filesystem with all the things needed to run your app (JVM, your source code, etc.), and docker container metadata, which tells the docker daemon how to run the app inside the image (e.g. what environment variables to set, what ports to expose, what commands to run, etc.). The docker daemon will use Linux features such as cgroups and kernel namespaces to run the container in isolation from other processes running on the host machine. Docker is somewhat low-level, in that you need to specify everything that goes into the image, and it runs arbitrary things, namely whatever you put into your image and tell it to run. The docker container that you get is very portable, so you can build, test, and run your docker container locally for development, and then ship that container to a production host that also has a docker daemon running on it, and be quite confident that you're getting the exact same thing.

Cloud Foundry works at a higher layer of abstraction, with applications being a first class concept. Cloud Foundry uses containerization technology similar to docker to build portable images and then run them, but it's an implementation detail and you don't need to specify all the details. In newer versions of Cloud Foundry, docker images will also be supported so you can specify the details if you want, but it also has a "buildpack" workflow, where it will automatically detect a Java application when you push your app and will know to include all the things necessary for the Java runtime when it builds the image.

With Cloud Foundry, since applications and application management are first class concepts, and since it operates at a higher level, you get all sorts of things for free. For instance, you can easily scale your app horizontally (add instances), e.g. cf scale my_app -i 5 or vertically, cf scale my_app -m 2G (to set the allocated memory for each instance). You get streaming application logs: cf logs my_app. Cloud Foundry gives you a lot of fault tolerance for free, so if one of your application instances crashes, or the process running the application containers itself crashes (the thing that's similar to the docker daemon), or if the host VM that's running the container-running process dies, or the hardware cluster where that VM resides dies, Cloud Foundry will automatically bring your instances back up.

The docker daemon is a single process you can run on any Linux machine. So if you're doing something small and simple, and you need to do most of the setup yourself, it can be easier to get up and running both locally and in development using docker. With docker it's also easier to have access and share the docker image you create, so once you've created an image, you can put it in a docker repository, and then you can run it on any other docker daemon. With Cloud Foundry, the built image is generally an implementation detail and you don't really have access to it, so for instance you couldn't extract that image and run it on another Cloud Foundry installation.

There are various projects out there intended to make Cloud Foundry more accessible and easier to set up, while still giving you many of the benefits of a PaaS. Some of these projects also aim to allow you to combine using docker and the benefits of docker while also getting a lot of the PaaS benefits you get from Cloud Foundry.

See Lattice and Cloud Foundry on BOSH-Lite.

There are also several hosted Cloud Foundry services.

See Pivotal Web Services and IBM BlueMix

There are also a lot of non-CF projects intended to put a platform layer around the core docker technology, in both run-your-own and hosted-service varieties.

See Google's Kubernetes project and Amazon Container Service

Full disclosure: I'm a software engineer working on Cloud Foundry at Pivotal

Amit Kumar Gupta
  • 17,184
  • 7
  • 46
  • 64
  • Does Cloud foundry support multiple Docker containers? and does it support more than one port? We want to install ELK stack and we need three ports. – powder366 Jan 24 '18 at 23:10
  • Are the ports for inbound traffic from the Internet, or for container-to-container communication? If the latter, then you should be able to do this. You can see how I deployed Spark on an instance of Cloud Foundry Application Service [here](https://gist.github.com/Amit-PivotalLabs/7c86c92aae3123ac809e81795a41acfa#deploy-the-spark-cluster), which involves pushing multiple Docker images and allowing them to talk to each other over hundreds of ports (since that's how Spark works apparently). – Amit Kumar Gupta Jan 25 '18 at 03:46
  • Inbound traffic from internet, i.e. use the normal Kibana and Elasticsearch WEB interface to name two. Also why dont the containers maintain state? We have data that we want to keep in the containers upon restarts. – powder366 Jan 25 '18 at 09:02
  • It worth to mention that by default Cloud Foundry use Garden for container management https://docs.cloudfoundry.org/concepts/architecture/garden.html You can configure CF to use Docker https://docs.cloudfoundry.org/adminguide/docker.html as an option – A B Nov 18 '18 at 20:01
  • 1
    @AB container runtime and supported image formats are separate concerns. When I wrote the response (2015), I said "[i]n newer versions of Cloud Foundry, docker images will also be supported." Docker images have been supported in Cloud Foundry for quite some time by now. Also, for quite some time now, Cloud Foundry's Diego scheduler talks to the Garden container runtime API, but the actual container runtime implementation has been swapped out for [runc](https://github.com/opencontainers/runc). – Amit Kumar Gupta Nov 18 '18 at 20:22