ERROR: (gcloud.preview) Invalid choice: 'docker'. Did you mean 'dm-v2'? - docker

Somehow I was able to push my docker image to Google Container Registry with command:
$ gcloud preview docker push gcr.io/<my-project-xxx>/<my-image-yyy>
I ran the commands yesterday and copied them to my notes, but today pasting them to terminal in the same order I get the error:
ERROR: (gcloud.preview) Invalid choice: 'docker'. Did you mean 'dm-v2'?
Why is that? where did teh "gcloud preview docker" command are then?

From the release notes 0.9.65 (2015/06/17):
gcloud preview docker moved to gcloud docker.
The command was moved out of preview in the latest version of gcloud. You can run it with:
gcloud docker push gcr.io/<my-project-xxx>/<my-image-yyy>

Related

Gcloud and docker confusion

I am very lost on the steps with gcloud verse docker. I have some gradle code that built a docker image and I see it in images like so
(base) Deans-MacBook-Pro:stockstuff-all dean$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
gcr.io/prod-stock-bot/stockstuff latest b041e2925ee5 27 minutes ago 254MB
I am unclear if I need to run docker push or not or if I can go strait to gcloud run deploy so I try a docker push like so
(base) Deans-MacBook-Pro:stockstuff-all dean$ docker push gcr.io/prod-stockstuff-bot/stockstuff
Using default tag: latest
The push refers to repository [gcr.io/prod-stockstuff-bot/stockstuff]
An image does not exist locally with the tag: gcr.io/prod-stockstuff-bot/stockstuff
I have no idea why it says the image doesn't exist locally when I keep listing the image. I move on to just trying gcloud run deploy like so
(base) Deans-MacBook-Pro:stockstuff-all dean$ gcloud run deploy stockstuff --project prod-stock-bot --region us-west1 --image gcr.io/prod-stockstuff-bot/stockstuff --platform managed
Deploying container to Cloud Run service [stockstuff] in project [prod-stock-bot] region [us-west1]
X Deploying... Image 'gcr.io/prod-stockstuff-bot/stockstuff' not found.
X Creating Revision... Image 'gcr.io/prod-stockstuff-bot/stockstuff' not found.
. Routing traffic...
Deployment failed
ERROR: (gcloud.run.deploy) Image 'gcr.io/prod-stockstuff-bot/stockstuff' not found.
I am doing this all as a playground project and can't seem to even get a cloud run deploy up and running.
I tried the spring example but that didn't even create a docker image and it failed anyways with
ERROR: (gcloud.run.deploy) Missing required argument [--image]: Requires a container image to deploy (e.g. `gcr.io/cloudrun/hello:latest`) if no build source is provided.
This error occurs when an image is not tagged locally/correctly. Steps you can try on your side.
Create image locally with name stockstuff (do not prefix it with gcr and project name while creating).
Tag image with gcr repo detail
$ docker tag stockstuff:latest gcr.io/prod-stockstuff-bot/stockstuff:latest
Check if your image is available in GCR (must see your image here, before deploying on cloudrun).
$ gcloud container images list --repository gcr.io/prod-stockstuff-bot
If you can see your image in list, next you can try to deploy gcloud run with below command (as yours).
gcloud run deploy stockstuff --project prod-stock-bot --region us-west1 --image gcr.io/prod-stockstuff-bot/stockstuff --platform managed
There are 3 contexts that you need to be aware.
Your local station, with your own docker.
The cloud based Google Container Registry: https://console.cloud.google.com/gcr/
Cloud Run product from GCP
So the steps would be:
Build your container either locally or using Cloud Build
Push the container to the GCR registry,
if you built locally
docker tag busybox gcr.io/my-project/busybox
docker push gcr.io/my-project/busybox
Deploy to Cloud Run a container from Google Cloud Repository.
I don't see this image gcr.io/prod-stockstuff-bot/stockstuff when you list images in the local system. You can create a new image by tagging that image with this image gcr.io/prod-stock-bot/stockstuff and re-run the gcloud run command.
for the context I am using Flask (python)
I solved this by
update gcloud-sdk to the latest version
gcloud components update
add .dockerignore, I'm guessing because of the python cache
Dockerfile
README.md
*.pyc
*.pyo
*.pyd
__pycache__
.pytest_cache
expose the port to env $PORT
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 app:app

What is the correct upload URL for a Dockerhub repo

I am following the instructions for the custom-vision service on raspberry-pi on IOT edge.
I have reached step 3, where in VS Code I am executing Build and Push to IOT Edge Solution and this is triggering the following command:
docker build --rm -f "/Users/myname/Dropbox/Dev/azure/custom-vision/Custom-vision-service-iot-edge-raspberry-pi/modules/CameraCapture/arm32v7.Dockerfile" -t registry.hub.docker.com/v1/repositories/myname/iot-hub-1/cameracapture:0.2.7-arm32v7 "/Users/myname/Dropbox/Dev/azure/custom-vision/Custom-vision-service-iot-edge-raspberry-pi/modules/CameraCapture"
&& docker push registry.hub.docker.com/v1/repositories/myname/iot-hub-1/cameracapture:0.2.7-arm32v7
&& docker build --rm -f "/Users/myname/Dropbox/Dev/azure/custom-vision/Custom-vision-service-iot-edge-raspberry-pi/modules/ImageClassifierService/arm32v7.Dockerfile" -t registry.hub.docker.com/v1/repositories/myname/iot-hub-1/imageclassifierservice:0.2.4-arm32v7 "/Users/myname/Dropbox/Dev/azure/custom-vision/Custom-vision-service-iot-edge-raspberry-pi/modules/ImageClassifierService"
&& docker push registry.hub.docker.com/v1/repositories/myname/iot-hub-1/imageclassifierservice:0.2.4-arm32v7
Which is failing with 404 - page not found.
I also tried using cloud.docker.com/repository/registry-1.docker.io/myname/iot-hub-1 but this gave me a different error:
invalid argument
"cloud.docker.com/repository/docker/myname/iot-hub-1:latest/cameracapture:0.2.7-arm32v7"
for "-t, --tag" flag: invalid reference format
Can anyone assist with the correct URL path, or some the additional steps i need to uploading the containers to my docker hub repository?
I couldn't find the correct URL for dockerhub, but Azure Container Registry was able to resolve my problem.
Details of the URL are here: Raspberry PI / IOTEdge failing to pull from Azure Container Registry
You need docker login first. Then build image docker build -t <docker_hub_username>/<app_name>:<tag> and then just push docker push <docker_hub_username>/<app_name>:<tag>. You don't need to specify any specific URL for Docker Hub.
Use this:
docker push <hub-user>/<repo-name>:<tag>
i.e
docker push username/reponame:latest

Access Docker Container from project registry

So I have my docker image uploaded to my projects registry. I can navigate to https://console.cloud.google.com/gcr/images/ and I see my Image listed there.
Now I want to run a VM on this project and on this one use docker to run this very image.
This is the command within my VM:
sudo /usr/bin/docker run eu.gcr.io/my-project-name/example001
The response is:
Unable to find image 'eu.gcr.io/.../example001:latest' locally
/usr/bin/docker: Error response from daemon: unauthorized: You don't have the needed permissions to perform this op
eration, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.goo
gle.com/container-registry/docs/advanced-authentication.
See '/usr/bin/docker run --help'.
Please see the image attached. I can list my images if I define "eu.gcr.io/..." as my project path. However the machine seems to run on ".gcr.io" so therefor not able to access my image? How would I fix this - and why is my image on "eu.gcr.io" and the machine on ".gcr.io", I cant find a method to change this (either move the image to gcr.io or move the machine to, eu.gcr.io). However I'm not sure if this is the issue.
Maybe it is an authentication issue with docker?
VM basically cannot be on ".gcr.io", it can run in non-European region/zone, but it shouldn't be a problem.
From GCP access control point of view registry is just a bucket.
So I believe first thing you need to check is that VM has access to Google Cloud Storage.
With gcloud:
gcloud compute instances describe <instance-name>
check if VM has scope to read from devstorage:
serviceAccounts:
- email: ...-compute#developer.gserviceaccount.com
scopes:
- https://www.googleapis.com/auth/devstorage.read_only
- ...
This scope should be in place to read from registry:
https://www.googleapis.com/auth/devstorage.read_only
If you don't have such scope on VM, but have there gcloud configured, you can use gcloud as credential helper:
gcloud auth configure-docker
as stated in doc you referred: https://cloud.google.com/container-registry/docs/advanced-authentication#gcloud_as_a_docker_credential_helper
The answer is found here:
https://serverfault.com/questions/900026/gcp-no-access-to-container-registry-from-compute-engine
It is the docker command which needs the authorization. Not the hostname (eu.gcr.io) is the issue here. I used 'gcloud docker -- pull ...' command to get the image from the repository to use within my VM.
after you create linux VM on GCP, SSH to it, you have to install Google SDK 1 using Cloud SDK with scripts]1 or manually.
If you are running Ubuntu follow the documentation here if you are installing with Red Hat or CentOS follow the documentation here after finishing the Google SDK you have to Run gcloud init to initialize the SDK, just open a terminal and tape [gcloud init] you have to configure your profile. after that you have to install Docker
sudo apt-get -y install docker-ce
sudo systemctl start docker
You need to have access to the registries which you will be pushing to and pulling from.
Configured Docker to use gcloud as a credential helper. To use gcloud as the crediential helper, run the command:
gcloud auth configure-docker
After that you can pull or push images on your registry using the gcloud command with the docker as shown below:
Push: gcloud docker -- push gcr.io/google-containers/example-image:latest
pull: gcloud docker -- pull gcr.io/google-containers/example-image:latest

Creating first image on bluemix docker

I'm trying to create a simple ubuntu image on docker within Bluemix.
I have the cli setup (at the latest version) but keep getting a login prompt when trying to push the image.
My dockerfile is trivial:
FROM docker.io/ubuntu:latest
MAINTAINER My Name
RUN echo "Imaged" > /tmp/image.txt
I build it with
sudo docker build -t ubuntu
then tag it with
sudo docker tag ubuntu registry.eu-gb.bluemix.net/MYNAMESPACE/ubuntu
I login with
cf login
Then push with
[ibmcloud#analyticsadmin docker]$ sudo docker push registry.ng.bluemix.net/MYNAMESPACE/ubuntu
The push refers to a repository [registry.ng.bluemix.net/MYNAMESPACE/ubuntu] (len: 1)
Sending image list
Please login prior to push:
Username:
I'm new to bluemix/docker so user error is highly likely. Can you spot my error? My DOCKER* environment variables are set as appropriate for my bluemix container service.
It seems you missed the step to login to the IBM Containers registry, that's why docker push is asking you for the username.
After cf login you have to run the following command as well:
$ cf ic login
This will authenticate you to the IBM Containers registry so you can push your images.
Please note that ic is a plugin you have to install for the cf command line interface. If you have not installed it yet please see instructions in the following link:
https://www.ng.bluemix.net/docs/containers/container_cli_cfic.html#container_cli_cfic_install
For example to install plugin in Linux system run the following command:
$ cf install-plugin https://static-ice.ng.bluemix.net/ibm-containers-linux_x64
A typo I see in your commands is that you tag your container for sending it to the UK data center (eu-gb) then try to push it to the south US one (ng), that's why I think the second command asks you to login.

docker push fails with status 400

My boot2docker push is failing with the following error.
Error: Status 400 trying to push repository abc/pentaho1: "Access denied: 8dc6a04270dfb41460bd53968e31b14da5414501c935fb67cf25975af9066925 is a private image"
my username on dockerhub is abc.
I created an image with tag abc/pentaho1/
These are the steps i followed to push the image:
docker build -t abc/pentaho1
docker login (successful)
docker push abc/pentaho1:latest
(I also tried the push command without the word latest)
I created a repository on my dockerhub with name pentaho1. It is not private.
Yet i see the above error.
Also i tried the following command. the results are empty.
bash-3.2$ docker images -a | grep
8dc6a04270dfb41460bd53968e31b14da5414501c935fb67cf25975af9066925
bash-3.2$
Can somebody help.
This issue can be resolved by upgrading to docker 1.6

Resources