How to connect docker to container - Google Cloud Platform / Kubernetes

I have a container application running in a virtual machine. It consists of two docker containers. The first contains a WebSphere Liberty server and web application. The second contains PostgreSQL and DB applications.

In my local virtual machine, I just use docker run to start the two containers, and then I use docker attach to attach to the web server container so that I can edit server.xml to specify the IP address of the public host for the database, and then run the web server in the container. The application is working fine.

Now I'm trying to deploy the application to the Google Cloud Platform.

  • I set the gcloud configuration (project, calculate / zone).
  • I created a cluster.
  • I created a JSON pod configuration file that points to both containers.
  • I created a pod.
  • I opened the firewall for the port specified in the pod configuration file.

In this moment:

  • I look at the container ( gcloud preview container kubectl get pods ), it shows how both containers work.
  • I am SSH for the cluster ( gcloud compute ssh xxx-mycluster-node -1 ) and it displays sudo docker ps and it shows how the database container works, but not the web server container. With sudo docker ps -l I see a web server container that doesn't work, but it keeps trying to start and exit every 10 seconds or so.

So, now I need to update server.xml and start the Liberty server, but I do not know how to do this in this area. Can I connect to a web server container like in a local virtual machine? Any help would be greatly appreciated. Thanks.

+7
google-container-engine kubernetes google-cloud-platform
source share
2 answers

Yes, you can attach the container to the container. Using Kubernetes 1.0, issue the following command:

do:

  • kubectl get po to get the POD name
  • kubectl describe po POD-NAME to find container name

Then:

kubectl exec -it POD-NAME -c CONTAINER-NAME bash Assuming you have bash

Similar to docker exec -it CONTAINER-NAME WHAT_EVER_LOCAL_COMMAND

+19
source share

On the machine itself, you can see containers with a torsional cycle with:

docker ps -a

and then

docker magazines

you can also use kubectl get pod -oyaml to get details, such as a restart count, which will verify that the container is cyclically completed.

0
source share

All Articles