I'll skip it until I get to the gcloud command line tools.
gcloud auth list
output:
Credentialed accounts:
- <myaccount>@<mydomain>.com (active)
gcloud config list project
output:
[core]
project = <project_ID>
Hello the world
docker run hello-world
pull
ed from Dockerhub with Docker imagesdocker images
output
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest XXXXXXXXX X days ago X.XX kB
docker ps
If you enter -a
, containers that have not been started will also be displayed.
Build
mkdir test && cd test
docker build -t [image name]:0.1 .
-t
maps the image name to the tag name. name: tag
If you do not define a tag
name, it will be recorded as latest
by default.
Run
docker run -p 4000:80 --name my-app [image name]:0.1
You can name the container name with --name
.
Stop
and rm
the containerdocker stop my-app && docker rm my-app
docker run -p 4000:80 --name my-app -d [image name]:0.1
Use -d
.
docker logs [container_id]
If you want to check the container log, execute the above command. If you can identify the container with the first few letters of container_id
, you don't have to enter all the ids.
docker build -t [image name]:0.2 .
docker run -p 8080:80 --name my-app-2 -d [image name]:0.2
curl http://localhost:8080
Check if the container was built correctly.
docker logs -f [container_id]
If you want to check the log while moving the container, use -f
.
Publish
[hostname]= gcr.io [project-id]= your project's ID [image]= your image name [tag]= any string tag of your choice. If unspecified, it defaults to "latest".
gcloud config list project
Find out the project ID.
docker tag [image name]:0.2 gcr.io/[project-id]/[image name]:0.2
Tag the image.
docker push gcr.io/[project-id]/[image name]:0.2
Push the image to gcr.
You can see the image pushed in Navigation menu
> Container Registry
. You can also check it at http://gcr.io/[project-id]/[image name]
.
docker stop $(docker ps -q)
docker rm $(docker ps -aq)
You can stop and delete the container in the development environment.
docker rmi [image name]:0.2 gcr.io/[project-id]/[image name] [image name]:0.1
docker rmi [image name]:[tag]
docker rmi $(docker images -aq)
docker images
After deleting the child image, delete the parent image.
docker pull gcr.io/[project-id]/[image name]:0.2
docker run -p 4000:80 -d gcr.io/[project-id]/[image name]:0.2
curl http://localhost:4000
If you want to start the container again in the development environment, docker pull
the image stored by gcr and docker run
.
Recommended Posts