How to use Java Buildpack in Bluemix Docker? - docker

I am new to Bluemix and docker. I want to use Java buildpack instead of the default IBMLiberty in docker container on Bluemix.
is it possible? I tried searching on internet but could not find relevant information.

Buildpack and docker (IBM Container) images are two different things.
The IBMLiberty docker/container images has a Liberty runtime deployed on it, but it is not using buildpack technology.
If you don't want to use IBMLiberty container images, you can load docker hub images into your private registry. The link below contains the information.
https://console.ng.bluemix.net/docs/containers/container_images_pulling.html
Basically, you load a docker hub image locally and push it to your private registry in Bluemix. One of the image choice is ubuntu.
https://hub.docker.com/_/ubuntu/
After you loaded the image to your private registry, you can use "cf ic run" to run a container using that image. Here is the reference,
https://console.ng.bluemix.net/docs/containers/container_cli_reference_cfic.html#container_cli_reference_cfic__run
Here are more info on using Docker image on Bluemix and cf ic commands,
https://console.ng.bluemix.net/docs/containers/container_images_adding_ov.html
https://console.ng.bluemix.net/docs/containers/container_cli_reference_cfic.html

Related

Can you download a docker image from a repository to a docker container without a running docker daemon?

I have a docker container with Trivy installed.
I have a remote registry with docker images.
and
I would like to download the docker images to the container for scanning
Challenges
It is hard to run docker within a docker container for pulling the images.
Trivy requires that you have the images locally before it can scan the images, either in a local registry or as a file.
I found two solutions:
Download the images with Skopeo
Download the images with the HTTP API V2
For the API I had a hard time making the authentication work, as it is repository specific, and Scaleways' authentication had unexpected behaviour.

GCE doesn't deploy GCR image correctly

I have followed this guide from Google documentation in order to be able to push a custom Docker image to Google Container Registry and then be able to start a new GCE instance with this image. At first I wanted to try using an anaconda3 public image from docker hub without any modification (in order to test).
So here is the steps I have done so far after installing gcloud and docker:
gcloud auth configure-docker -> configured docker with my gcloud crendentials
docker pull continuumio/anaconda3 -> pulled the public image
docker tag continuumio/anaconda3 eu.gcr.io/my-project-id/anaconda3 -> tagged the local image with the registry name as specified in the doc
docker push eu.gcr.io/my-project-id/anaconda3 -> pushed the image to GCR
Good ! I am now able to see my image trough GCR interface, and also able to deploy it with GCE. I choose to deploy it with a f1-micro instance, Container-Optimized OS 67-10575.62.0 stable, 10 Go boot disk, Allow HTTP traffic, etc.
But when I connect with ssh to the freshly new created VM instance, I can't find anaconda3 librairies (which are supposed to be created in /opt/conda). Instead, I can see a /opt/google directory which makes me think that the image has not been deployed correctly and GCE is using a default image...
So I tried to check if the image was pushed correctly in GCR, so I decided to delete my local image and pull it once again from GCR:
docker rmi -f eu.gcr.io/my-project-id/anaconda3
docker pull eu.gcr.io/my-project-id/anaconda3:latest
I run the image
docker run -t -i eu.gcr.io/my-project-id/anaconda3
and I can see that everything is fine, I have anaconda3 installed correctly inside /opt/conda with all the toolts needed (Pandas, Numpy, Jupyter notebook, etc.)
I tried to find people with the same problem as me without any success... maybe I have done something wrong in my proccess ?
Thanks !
TL;DR My problem is that I have pushed an anaconda3 image on Google GCR, but when I launch a virtual instance with this image, I do not have anaconda on it
It's normal that you can't find anaconda libraries installed directly on the GCE instance.
Actually, when you choose to deploy a container image on a GCE VM instance, a Docker container is started from the image you provide (in your example, eu.gcr.io/my-project-id/anaconda3). The libraries are not installed on the host, but rather inside that container (run docker ps to see it, but normally it has the same name as your VM instance). If you run something like :
docker exec -it <docker_container_name> ls /opt/conda
Then you should see the anaconda libraries, only existing inside the container.
When you run docker run -t -i eu.gcr.io/my-project-id/anaconda3, you're actually starting the container and running an interactive bash session inside that container (see the CMD here). That's why you can find anaconda libraries : you are inside the container!
Containerization software (docker here) provides isolation between your host and your containers. I'll suggest you to read documentation about containerization, Docker and how to run containers on Container-Optimized OS.

Make Nginx image available in local/private repository for production safe perspective in kubernetes

How can we make nginx image available in my local/private repository in kubernetes?
Lets say i am using nginx image tag version x.x. I have tested it in my dev and test env and want to move it to prod.
What if the image is not present in nginx repository?
Is there a way to pull the x.x version of nginx to our local/private repository?
There is a high risk if the image is not available. So it would be helpful if anyone guide me how we handle this.
If you have docker installed in your machine, pull docker image
$ docker pull nginx:x.x
Now, you can't use this local docker image inside Kubernetes. You need to do additional thing
Push this image into your docker registry in cloud.
$ docker tag nginx:x.x <your-registry>/nginx:x.x
$ docker push <your-registry>/nginx:x.x
And then use <your-registry>/nginx:x.x from your registry.

docker difference between private registry and the local image registry?

I have something on my mind that is bugging me. When running docker images I see a list of my local images I have in my docker environment. When pulling Images I pull it from a registry and more specific pull the specified tag managed by the repository.
so there is the registry as the big hub to store all image
repositories
and the repository is storing commits/tagged versions of a specific image
But what is docker images then? It's a registry as well isn't it? It holds all images that I've built locally or pulled.
If my claim is valid:
How does it comply with running a private registry (mentioned here https://docs.docker.com/registry/deploying/)
Running this docker run -d -p 5000:5000 --restart=always --name registry registry:2
Would deploy this new registry into my docker images...
So now I have a registry within my registry... registception?
What is the difference besides the custom registry is deployable?
Its not a local image registry as other questions have pointed. It is an image cache. The purpose of the image cache is to avoid having every time to download the same image whenever you do a docker run.
docker images simply lists all the cached images on the machine. Whenever there is newer image on the registry, the image(some layers) are downloaded and cached when doing docker pull .... Also, when a layer exists in the local cache, docker tells you that, example:
Step 2/2 : CMD /bin/bash
---> Using cache
On the other hand, a docker registry is a central repository to store images. It provide a remote api to pull and push images. The local image cache does not have this feature. Images in the local cache are read and stored used local docker commands that simply read files under /var/lib/docker/...
To make things clear, think of Docker remote registries (such as Docker Hub) as the remote Git repositories. You pull Docker images (like git repositories) that you need and you play with it.
Like remote Git repositories such as GitHub\BitBucket, Docker registries are also public and private. Public registries are for public usage and open-source projects. Examples include in like Docker Hub. Where as private registries are for organizational use or for your own. Examples for private registries include Azure Container Registry, EC2 Container Registry etc.
The official Docker Registry image is just a Docker registry image for your own system, you can't share them with others unless you have a server or a public Internet IP address. Think of it as Bonobo Private Git Server for Windows.
Your local image registry as you mentioned are all those images that you have build locally or pulled from a registry public or private you can see it like a local cache of images that you can re use without download or rebuild each time.
Running the registry what actually does is to spin up a server that implements the Docker Registry API which allows users to push, pull, delete and handles the storage of this images and their layers. See it like a central repository like npm, nexus
For example if you run the registry in your.registry.com:5000
You can do things like
docker build -t your.registry.com:5000/my-image:tag .
docker push your.registry.com:5000/my-image:tag
So others that have access to your server can pull it
docker pull your.registry.com:5000/my-image:tag

How I use a local container in a swarm cluster

A colleague find out Docker and want to use it for our project. I start to use Docker for test. After reading an article about Docker swarm I want to test it.
I have installed 3 VM (ubuntu server 14.04) with docker and swarm. I followed some How To ( http://blog.remmelt.com/2014/12/07/docker-swarm-setup/ and http://devopscube.com/docker-tutorial-getting-started-with-docker-swarm/). My cluster work. I can launch for exemple a basic apache container (the image was pull in the Docker hub) but I want to use my own image (an apache server with my web site).
I tested to load an image (after save it in a .tar) but this option isn't supported by the clustering mode, same thing with the import option.
So my question is : Can I use my own image without to push it in the Docker hub and how I do this ?
If your own image is based on a Dockerfile that you build you can execute the build command on your project while targeting the swarm.
However if the image wasn't built, but created manually you need to have a registry in between that you can push to, either docker hub or some other registry solution like https://github.com/docker/docker-registry

Resources