简体   繁体   中英

Deploying web service application using Docker

I'm using Docker to deploy my web service to GCE and I'm following the instructions given here: https://blog.golang.org/docker

I have created a private repository on Bitbucket, made an automated build and I'm able to run my build with "docker run namespace/repo" remembering to run "docker login" beforehand (!).

Now, creating the GCE instance succeeds without errors, but my image is not running (using "sudo docker ps")

How can I setup the containers.yaml to install private Docker images?

Below is my containers.yaml file:

version: v1beta2
containers:
- name: my-webservice
  image: namespace/repo:latest
  ports:
  - name: http
    hostPort: 80
    containerPort: 8080

Unfortunately, I don't see anything in the manifest that would let you specify the login credentials in the manifest spec , but there might be a way to workaround it.

You can run startup scripts, so try to create one with

#!/bin/sh
docker login -u your_user -p yourpassword

Then add the startup script to your instance with

gcloud compute instances add-metadata yourvmname \
--metadata-from-file startup-script=yourshellscript.sh 

That should run that script before docker starts and have you logged in when it pulls the images.

If that doesn't work, there is a method to load docker images from your cloud storage bucket called docker-registry-driver-gcs. You can see the example here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM