Docker is an open platform for developing, shipping, and running applications.
With Docker, you can separate your applications from your infrastructure and treat your infrastructure like a managed application.
Docker helps you ship code faster, test faster, deploy faster, and shorten the cycle between writing code and running code.
Docker does this by combining kernel containerization features with workflows and tooling that helps you manage and deploy your applications.
Docker containers can be directly used in Kubernetes, which allows them to be run in the Kubernetes Engine with ease. After learning the essentials of Docker, you will have the skillset to start developing Kubernetes and containerized applications.
In this lab, you will learn how to do the following:
• How to build, run, and debug Docker containers.
• How to pull Docker images from Docker Hub and Google Artifact Registry.
• How to push Docker images to Google Artifact Registry.
elcome to Cloud Shell! Type "help" to get started.
Your Cloud Platform project in this session is set to qwiklabs-gcp-00-b963d48bc95a.
Use “gcloud config set project [PROJECT_ID]” to change to a different project.
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ gcloud auth list
Credentialed Accounts
ACTIVE: *
ACCOUNT: student-02-f6b847233541@qwiklabs.net
To set the active account, run:
$ gcloud config set account `ACCOUNT`
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker --version
Docker version 24.0.4, build 3713ee1
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
719385e32844: Pull complete
Digest: sha256:926fac19d22aa2d60f1a276b66a20eb765fbeea2db5dbdaafeb456ad8ce81598
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 9c7a54a9a43c 2 months ago 13.3kB
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
82154a06a2fc hello-world "/hello" 19 seconds ago Exited (0) 18 seconds ago practical_cerf
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
3153aa388d02: Pull complete
Digest: sha256:0bced47fffa3361afa981854fcabcd4577cd43cebbb808cea2b1f33a3dd7f508
Status: Downloaded newer image for ubuntu:latest
root@18463f62ccd2:/# curl http://localhost:4000
bash: curl: command not found
root@18463f62ccd2:/# curl http://localhost:4000
bash: curl: command not found
root@18463f62ccd2:/# curl
bash: curl: command not found
root@18463f62ccd2:/# exit
exit
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ curl http://localhost:4000
Hello World
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker run -it ubuntu bash
root@ceeb9f314192:/#
root@ceeb9f314192:/#
root@ceeb9f314192:/#
root@ceeb9f314192:/# apt-get install curl
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package curl
root@ceeb9f314192:/#
root@ceeb9f314192:/#
root@ceeb9f314192:/# exit
exit
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
node-app 0.1 fc997911eb07 5 minutes ago 1.09GB
ubuntu latest 5a81c4b8502e 4 weeks ago 77.8MB
const http = require('http');
const hostname = '0.0.0.0';
hello-world latest 9c7a54a9a43c 2 months ago 13.3kB
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
39c61044094f node-app:0.1 "docker-entrypoint.s…" About a minute ago Up About a minute 0.0.0.0:4000->80/tcp my-app
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$
const http = require('http');
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ceeb9f314192 ubuntu "bash" 36 seconds ago Exited (100) 18 seconds ago determined_agnesi
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
39c61044094f node-app:0.1 "docker-entrypoint.s…" About a minute ago Up About a minute 0.0.0.0:4000->80/tcp my-app
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ceeb9f314192 ubuntu "bash" 55 seconds ago Exited (100) 37 seconds ago determined_agnesi
39c61044094f node-app:0.1 "docker-entrypoint.s…" 2 minutes ago Up About a minute 0.0.0.0:4000->80/tcp my-app
c3429a31517a hello-world "/hello" 14 minutes ago Exited (0) 14 minutes ago pedantic_rosalind
006e4fd82211 hello-world "/hello" 14 minutes ago Exited (0) 14 minutes ago vibrant_borg
18463f62ccd2 ubuntu "bash" 17 minutes ago Exited (127) About a minute ago confident_northcutt
82154a06a2fc hello-world "/hello" 19 minutes ago Exited (0) 19 minutes ago practical_cerf
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker stop my-app && docker rm my-app
my-app
my-app
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
node-app 0.1 fc997911eb07 6 minutes ago 1.09GB
ubuntu latest 5a81c4b8502e 4 weeks ago 77.8MB
hello-world latest 9c7a54a9a43c 2 months ago 13.3kB
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ceeb9f314192 ubuntu "bash" 2 minutes ago Exited (100) About a minute ago determined_agnesi
c3429a31517a hello-world "/hello" 15 minutes ago Exited (0) 15 minutes ago pedantic_rosalind
006e4fd82211 hello-world "/hello" 16 minutes ago Exited (0) 16 minutes ago vibrant_borg
18463f62ccd2 ubuntu "bash" 19 minutes ago Exited (127) 2 minutes ago confident_northcutt
82154a06a2fc hello-world "/hello" 20 minutes ago Exited (0) 20 minutes ago practical_cerf
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker run -p 4000:80 --name my-app -d node-app:0.1
db70087920a99c37043eceb8059defe64f35d84e07460b006d9d78c830581768
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
db70087920a9 node-app:0.1 "docker-entrypoint.s…" 22 seconds ago Up 22 seconds 0.0.0.0:4000->80/tcp my-app
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker logs ^C
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker logs db70087920a9
Server running at http://0.0.0.0:80/
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ cd test
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ ls
app1 app.js Dockerfile
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ vi app.js
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ cp app.js app.orig
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ vi apps.js
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ ls
app1 app.js app.orig Dockerfile
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ vi app.js
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker build -t node-app:0.2 .
[+] Building 0.4s (8/8) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 393B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/node:lts 0.3s
=> [1/3] FROM docker.io/library/node:lts@sha256:c85dc4392f44f5de1d0d72dd20a088a542734445f99bed7aa8ac895c706d370d 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 1.07kB 0.0s
=> CACHED [2/3] WORKDIR /app 0.0s
=> [3/3] ADD . /app 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:8662f116ddc3f8fbf0ae3e9e16bf2ea691cacc6c6342d065c354733fa18d3864 0.0s
=> => naming to docker.io/library/node-app:0.2 0.0s
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
node-app 0.2 8662f116ddc3 6 seconds ago 1.09GB
node-app 0.1 fc997911eb07 13 minutes ago 1.09GB
ubuntu latest 5a81c4b8502e 4 weeks ago 77.8MB
hello-world latest 9c7a54a9a43c 2 months ago 13.3kB
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker run -p 8080:80 --name my-app-2 -d node-app:0.2
eaa665d80271ba6c163c1eb1f8d72b5a61f775d18fd87df8fe764f5abe2797a6
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
eaa665d80271 node-app:0.2 "docker-entrypoint.s…" 3 seconds ago Up 3 seconds 0.0.0.0:8080->80/tcp my-app-2
db70087920a9 node-app:0.1 "docker-entrypoint.s…" 5 minutes ago Up 5 minutes 0.0.0.0:4000->80/tcp my-app
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ curl http://localhost:4000
Hello World
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ curl http://localhost:8080
Welcome to Ketan Cloud - Hello World
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker logs -f ^C
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ eaa665d80271
-bash: eaa665d80271: command not found
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker logs -f eaa665d80271
Server running at http://0.0.0.0:80/
^C
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker logs -f ^C
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker logs -f db70087920a9
Server running at http://0.0.0.0:80/
^C
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ history
1 gcloud auth list
2 docker --version
3 docker images
4 docker ps
5 docker ps -a
6 docker run hello-world
7 docker images
8 docker ps
9 docker ps -a
10 docker run -it ubuntu bash
11 curl http://localhost:4000
12 docker run -it ubuntu bash
13 docker images
14 docker ps
15 docker ps -l
16 docker ps
17 docker ps -a
18 docker stop my-app && docker rm my-app
19 docker images
20 docker ps
21 docker ps -a
22 docker run -p 4000:80 --name my-app -d node-app:0.1
23 docker ps
24 docker logs db70087920a9
25 cd test
26 ls
27 vi app.js
28 cp app.js app.orig
29 vi apps.js
30 ls
31 vi app.js
32 docker build -t node-app:0.2 .
33 docker images
34 docker run -p 8080:80 --name my-app-2 -d node-app:0.2
35 docker ps
36 curl http://localhost:4000
37 curl http://localhost:8080
38 eaa665d80271
39 docker logs -f eaa665d80271
40 docker logs -f db70087920a9
41 history
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
cat > Dckerfile <<EOF
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
18463f62ccd2 ubuntu "bash" 3 minutes ago Up 2 minutes confident_northcutt
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
006e4fd82211 hello-world "/hello" 8 seconds ago Exited (0) 7 seconds ago vibrant_borg
cat > Dckerfile <<EOF
cat > app.js <<EOF
18463f62ccd2 ubuntu "bash" 3 minutes ago Up 3 minutes confident_northcutt
82154a06a2fc hello-world "/hello" 4 minutes ago Exited (0) 4 minutes ago practical_cerf
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c3429a31517a hello-world "/hello" 3 seconds ago Exited (0) 2 seconds ago pedantic_rosalind
006e4fd82211 hello-world "/hello" 23 seconds ago Exited (0) 22 seconds ago vibrant_borg
18463f62ccd2 ubuntu "bash" 3 minutes ago Up 3 minutes confident_northcutt
82154a06a2fc hello-world "/hello" 4 minutes ago Exited (0) 4 minutes ago practical_cerf
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$
cat > app.js <<EOF
const http = require('http');
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~ (qwiklabs-gcp-00-b963d48bc95a)$ mkdir test ; cd test
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ vi Dockerfile
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ cat Dockerfile
cat > Dckerfile <<EOF
# Use an official Node runtime as the parent image
FROM node:lts
# Set the working directory in the container to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
ADD . /app
# Make the container's port 80 available to the outside world
EXPOSE 80
# Run app.js using node when the container launches
CMD ["node", "app.js"]
cat > Dockerfile <<EOF
EOF
cat > app.js <<EOF
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ vi Dockerfile
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ cat Dockerfile
cat > app.js <<EOF
const http = require('http');
const hostname = '0.0.0.0';
const port = 80;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World\n');
});
server.listen(port, hostname, () => {
console.log('Server running at http://%s:%s/', hostname, port);
});
process.on('SIGINT', function() {
console.log('Caught interrupt signal and will exit');
process.exit();
});
EOF
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker build -t node-app:0.1 .
[+] Building 0.1s (2/2) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 521B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
Dockerfile:1
--------------------
1 | >>> cat > app.js <<EOF
2 | const http = require('http');
cat > Dockerfile <<EOF
# Use an official Node runtime as the parent image
3 | const hostname = '0.0.0.0';
--------------------
ERROR: failed to solve: dockerfile parse error on line 1: unknown instruction: cat (did you mean cmd?)
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ vi Dockerfile
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker build -t node-app:0.1 .
[+] Building 0.0s (2/2) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 498B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
Dockerfile:1
--------------------
1 | >>> const http = require('http');
2 | const hostname = '0.0.0.0';
3 | const port = 80;
--------------------
ERROR: failed to solve: dockerfile parse error on line 1: unknown instruction: const
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ vi Dockerfile
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ vi app1
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ cp app1 app.js
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ ./app.js
-bash: ./app.js: Permission denied
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ ls -l
total 12
-rw-r--r-- 1 student_02_f6b847233541 student_02_f6b847233541 482 Aug 1 20:20 app1
-rw-r--r-- 1 student_02_f6b847233541 student_02_f6b847233541 482 Aug 1 20:20 app.js
-rw-r--r-- 1 student_02_f6b847233541 student_02_f6b847233541 381 Aug 1 20:19 Dockerfile
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ chmod +x app.js
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ ls -l
total 12
-rw-r--r-- 1 student_02_f6b847233541 student_02_f6b847233541 482 Aug 1 20:20 app1
-rwxr-xr-x 1 student_02_f6b847233541 student_02_f6b847233541 482 Aug 1 20:20 app.js
-rw-r--r-- 1 student_02_f6b847233541 student_02_f6b847233541 381 Aug 1 20:19 Dockerfile
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ ./app.js
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker build -t node-app:0.1 .
[+] Building 0.0s (2/2) FINISHED docker:default
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 420B 0.0s
Dockerfile:1
--------------------
1 | >>> cat > Dockerfile <<EOF
2 | # Use an official Node runtime as the parent image
3 | FROM node:lts
--------------------
ERROR: failed to solve: dockerfile parse error on line 1: unknown instruction: cat (did you mean cmd?)
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ vi Dockerfile
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ ls -l
total 12
-rw-r--r-- 1 student_02_f6b847233541 student_02_f6b847233541 482 Aug 1 20:20 app1
-rwxr-xr-x 1 student_02_f6b847233541 student_02_f6b847233541 459 Aug 1 20:22 app.js
-rw-r--r-- 1 student_02_f6b847233541 student_02_f6b847233541 354 Aug 1 20:22 Dockerfile
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker build -t node-app:0.1 .
[+] Building 23.3s (8/8) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 393B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/node:lts 0.9s
=> [1/3] FROM docker.io/library/node:lts@sha256:c85dc4392f44f5de1d0d72dd20a088a542734445f99bed7aa8ac895c706d370d 20.8s
=> => resolve docker.io/library/node:lts@sha256:c85dc4392f44f5de1d0d72dd20a088a542734445f99bed7aa8ac895c706d370d 0.0s
=> => sha256:5a6dad8f55ae6c733e986316bd08205c8b2c41640bf8d08ff6e9bbcb6884304f 24.03MB / 24.03MB 0.4s
=> => sha256:a52ed7aa0ea502c2e06a1066c80a8adf4163d4edc47ee3257e573cd55a7828b0 2.00kB / 2.00kB 0.0s
=> => sha256:d9ad63743e7233472aa70512627f76b395381433585a4666d4adf5959b618294 7.24kB / 7.24kB 0.0s
=> => sha256:bd36c7bfe5f4bdffcc0bbb74b0fb38feb35c286ea58b5992617fb38b0c933603 64.11MB / 64.11MB 1.5s
=> => sha256:c85dc4392f44f5de1d0d72dd20a088a542734445f99bed7aa8ac895c706d370d 1.21kB / 1.21kB 0.0s
=> => sha256:785ef8b9b236a5f027f33cae77513051704c0538bff455ff5548105c954c3b1c 49.56MB / 49.56MB 0.9s
=> => sha256:4d207285f6d296b9806bd00340437406c25207412c52fcfcbf229a5ecff7bf94 211.03MB / 211.03MB 3.1s
=> => sha256:e1c045e015f50783735c775373c3c715886cbd38a7d2bc2397d1d144a8db2f50 3.37kB / 3.37kB 1.2s
=> => extracting sha256:785ef8b9b236a5f027f33cae77513051704c0538bff455ff5548105c954c3b1c 3.3s
=> => sha256:7b238747a438d66daf2806f5e86e82cfa50273b92f579441c7863fb203821fc0 45.78MB / 45.78MB 2.0s
=> => sha256:332e7d92ba93f359879c2e4e7a41b3148a6aac2bb8239d37511bd797ce18e1d8 2.28MB / 2.28MB 1.8s
=> => sha256:7718d827325f7469bba077c7f3b33d5cdd6d6aaf06ee37b89ce3a3679f223481 454B / 454B 2.1s
=> => extracting sha256:5a6dad8f55ae6c733e986316bd08205c8b2c41640bf8d08ff6e9bbcb6884304f 0.7s
=> => extracting sha256:bd36c7bfe5f4bdffcc0bbb74b0fb38feb35c286ea58b5992617fb38b0c933603 3.1s
=> => extracting sha256:4d207285f6d296b9806bd00340437406c25207412c52fcfcbf229a5ecff7bf94 8.9s
=> => extracting sha256:e1c045e015f50783735c775373c3c715886cbd38a7d2bc2397d1d144a8db2f50 0.0s
=> => extracting sha256:7b238747a438d66daf2806f5e86e82cfa50273b92f579441c7863fb203821fc0 2.8s
=> => extracting sha256:332e7d92ba93f359879c2e4e7a41b3148a6aac2bb8239d37511bd797ce18e1d8 0.1s
=> => extracting sha256:7718d827325f7469bba077c7f3b33d5cdd6d6aaf06ee37b89ce3a3679f223481 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 1.41kB 0.0s
=> [2/3] WORKDIR /app 1.4s
=> [3/3] ADD . /app 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:fc997911eb07328452f98d376dcb73a736893c31d7a2f871b1944991732837a0 0.0s
=> => naming to docker.io/library/node-app:0.1 0.0s
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
node-app 0.1 fc997911eb07 9 seconds ago 1.09GB
ubuntu latest 5a81c4b8502e 4 weeks ago 77.8MB
hello-world latest 9c7a54a9a43c 2 months ago 13.3kB
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
18463f62ccd2 ubuntu "bash" 12 minutes ago Up 12 minutes confident_northcutt
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c3429a31517a hello-world "/hello" 9 minutes ago Exited (0) 9 minutes ago pedantic_rosalind
006e4fd82211 hello-world "/hello" 9 minutes ago Exited (0) 9 minutes ago vibrant_borg
18463f62ccd2 ubuntu "bash" 12 minutes ago Up 12 minutes confident_northcutt
82154a06a2fc hello-world "/hello" 13 minutes ago Exited (0) 13 minutes ago practical_cerf
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker run -p 4000:80 --name my-app node-app:0.1
Server running at http://0.0.0.0:80/
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker exec -it db70087920a9 bash
root@db70087920a9:/app#
root@db70087920a9:/app#
root@db70087920a9:/app# ls
Dockerfile app.js app1
root@db70087920a9:/app# exit
exit
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker inspect db70087920a9
[
{
"Id": "db70087920a99c37043eceb8059defe64f35d84e07460b006d9d78c830581768",
"Created": "2023-08-01T20:31:16.352409059Z",
"Path": "docker-entrypoint.sh",
"Args": [
"node",
"app.js"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 1825,
"ExitCode": 0,
"Error": "",
"StartedAt": "2023-08-01T20:31:16.593482184Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:fc997911eb07328452f98d376dcb73a736893c31d7a2f871b1944991732837a0",
"ResolvConfPath": "/var/lib/docker/containers/db70087920a99c37043eceb8059defe64f35d84e07460b006d9d78c830581768/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/db70087920a99c37043eceb8059defe64f35d84e07460b006d9d78c830581768/hostname",
"HostsPath": "/var/lib/docker/containers/db70087920a99c37043eceb8059defe64f35d84e07460b006d9d78c830581768/hosts",
"LogPath": "/var/lib/docker/containers/db70087920a99c37043eceb8059defe64f35d84e07460b006d9d78c830581768/db70087920a99c37043eceb8059defe64f35d84e07460b006d9d78c830581768-json.log",
"Name": "/my-app",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "docker-default",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"80/tcp": [
{
"HostIp": "",
"HostPort": "4000"
}
]
},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"ConsoleSize": [
51,
258
],
"CapAdd": null,
"CapDrop": null,
"CgroupnsMode": "private",
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "private",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": [],
"BlkioDeviceWriteBps": [],
"BlkioDeviceReadIOps": [],
"BlkioDeviceWriteIOps": [],
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": null,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/6a5b7043e4520c83127d09790fd47c940a07d76aa8a7aa683148924955d51489-init/diff:/var/lib/docker/overlay2/yq9ylxm2t0s1fze1zntgitbtv/diff:/var/lib/docker/overlay2/toa1r8p5wv3tfzdj93r3l1n6h/diff:/var/lib/docker/overlay2/f7447b63d813b430c55745691fef6e033e00c572867a9d288d301e1d2da4f169/diff:/var/lib/docker/overlay2/aac25d3708198c0941abcd5435c6d56871fd167fb22a11b3078e6c9418f10458/diff:/var/lib/docker/overlay2/270396366f5668417ff5a98a2bfc64145a020a9d245d1f4da78a5817faa4d6b7/diff:/var/lib/docker/overlay2/d36a1c3e17d3ec27456ea3fd79f6153393c6f789a4b637cdfc92c0963a1f069a/diff:/var/lib/docker/overlay2/ece7b41081d5ccec456ac73b6e2cf53d27dbc5263ce98a238343a46fe8763e22/diff:/var/lib/docker/overlay2/0b5b34ce6ea5c2fdd2b7d7a20530024b6dd04d5016ab2b37618a94fc334a4db0/diff:/var/lib/docker/overlay2/6b5121d5f790b5e71141625b3716a94f059bef8bbeffc3ec0048e8754af8e87b/diff:/var/lib/docker/overlay2/4c852d10438209581530b02a8d93daaafc288566e48d2f4ace886220bbc8498e/diff",
"MergedDir": "/var/lib/docker/overlay2/6a5b7043e4520c83127d09790fd47c940a07d76aa8a7aa683148924955d51489/merged",
"UpperDir": "/var/lib/docker/overlay2/6a5b7043e4520c83127d09790fd47c940a07d76aa8a7aa683148924955d51489/diff",
"WorkDir": "/var/lib/docker/overlay2/6a5b7043e4520c83127d09790fd47c940a07d76aa8a7aa683148924955d51489/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "db70087920a9",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"80/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"NODE_VERSION=18.17.0",
"YARN_VERSION=1.22.19"
],
"Cmd": [
"node",
"app.js"
],
"Image": "node-app:0.1",
"Volumes": null,
"WorkingDir": "/app",
"Entrypoint": [
"docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "0c5c34487685247d01d10bcd2ce820ca354d4e5031ab04ef118f33d4cab59cd8",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"80/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "4000"
}
]
},
"SandboxKey": "/var/run/docker/netns/0c5c34487685",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "6b3b9538f318c91356a714a2fb1f784e3acaf0675303c92a427a50a57d856d12",
"Gateway": "172.18.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.18.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:12:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "d3f7923d6aec4161e0155a17beaef745383b198071ab56987d7e71d6833d476b",
"EndpointID": "6b3b9538f318c91356a714a2fb1f784e3acaf0675303c92a427a50a57d856d12",
"Gateway": "172.18.0.1",
"IPAddress": "172.18.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:12:00:02",
"DriverOpts": null
}
}
}
}
]
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker inspect db70087920a9
[
{
"Id": "db70087920a99c37043eceb8059defe64f35d84e07460b006d9d78c830581768",
"Created": "2023-08-01T20:31:16.352409059Z",
"Path": "docker-entrypoint.sh",
"Args": [
"node",
"app.js"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 1825,
"ExitCode": 0,
"Error": "",
"StartedAt": "2023-08-01T20:31:16.593482184Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:fc997911eb07328452f98d376dcb73a736893c31d7a2f871b1944991732837a0",
"ResolvConfPath": "/var/lib/docker/containers/db70087920a99c37043eceb8059defe64f35d84e07460b006d9d78c830581768/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/db70087920a99c37043eceb8059defe64f35d84e07460b006d9d78c830581768/hostname",
"HostsPath": "/var/lib/docker/containers/db70087920a99c37043eceb8059defe64f35d84e07460b006d9d78c830581768/hosts",
"LogPath": "/var/lib/docker/containers/db70087920a99c37043eceb8059defe64f35d84e07460b006d9d78c830581768/db70087920a99c37043eceb8059defe64f35d84e07460b006d9d78c830581768-json.log",
"Name": "/my-app",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "docker-default",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"80/tcp": [
{
"HostIp": "",
"HostPort": "4000"
}
]
},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"ConsoleSize": [
51,
258
],
"CapAdd": null,
"CapDrop": null,
"CgroupnsMode": "private",
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "private",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": [],
"BlkioDeviceWriteBps": [],
"BlkioDeviceReadIOps": [],
"BlkioDeviceWriteIOps": [],
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": null,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/6a5b7043e4520c83127d09790fd47c940a07d76aa8a7aa683148924955d51489-init/diff:/var/lib/docker/overlay2/yq9ylxm2t0s1fze1zntgitbtv/diff:/var/lib/docker/overlay2/toa1r8p5wv3tfzdj93r3l1n6h/diff:/var/lib/docker/overlay2/f7447b63d813b430c55745691fef6e033e00c572867a9d288d301e1d2da4f169/diff:/var/lib/docker/overlay2/aac25d3708198c0941abcd5435c6d56871fd167fb22a11b3078e6c9418f10458/diff:/var/lib/docker/overlay2/270396366f5668417ff5a98a2bfc64145a020a9d245d1f4da78a5817faa4d6b7/diff:/var/lib/docker/overlay2/d36a1c3e17d3ec27456ea3fd79f6153393c6f789a4b637cdfc92c0963a1f069a/diff:/var/lib/docker/overlay2/ece7b41081d5ccec456ac73b6e2cf53d27dbc5263ce98a238343a46fe8763e22/diff:/var/lib/docker/overlay2/0b5b34ce6ea5c2fdd2b7d7a20530024b6dd04d5016ab2b37618a94fc334a4db0/diff:/var/lib/docker/overlay2/6b5121d5f790b5e71141625b3716a94f059bef8bbeffc3ec0048e8754af8e87b/diff:/var/lib/docker/overlay2/4c852d10438209581530b02a8d93daaafc288566e48d2f4ace886220bbc8498e/diff",
"MergedDir": "/var/lib/docker/overlay2/6a5b7043e4520c83127d09790fd47c940a07d76aa8a7aa683148924955d51489/merged",
"UpperDir": "/var/lib/docker/overlay2/6a5b7043e4520c83127d09790fd47c940a07d76aa8a7aa683148924955d51489/diff",
"WorkDir": "/var/lib/docker/overlay2/6a5b7043e4520c83127d09790fd47c940a07d76aa8a7aa683148924955d51489/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "db70087920a9",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"80/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"NODE_VERSION=18.17.0",
"YARN_VERSION=1.22.19"
],
"Cmd": [
"node",
"app.js"
],
"Image": "node-app:0.1",
"Volumes": null,
"WorkingDir": "/app",
"Entrypoint": [
"docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "0c5c34487685247d01d10bcd2ce820ca354d4e5031ab04ef118f33d4cab59cd8",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"80/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "4000"
}
]
},
"SandboxKey": "/var/run/docker/netns/0c5c34487685",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "6b3b9538f318c91356a714a2fb1f784e3acaf0675303c92a427a50a57d856d12",
"Gateway": "172.18.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.18.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:12:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "d3f7923d6aec4161e0155a17beaef745383b198071ab56987d7e71d6833d476b",
"EndpointID": "6b3b9538f318c91356a714a2fb1f784e3acaf0675303c92a427a50a57d856d12",
"Gateway": "172.18.0.1",
"IPAddress": "172.18.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:12:00:02",
"DriverOpts": null
}
}
}
}
]
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' db70087920a9
172.18.0.2
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ gcloud auth configure-docker us-ce
WARNING: Your config file at [/home/student_02_f6b847233541/.docker/config.json] contains these credential helper entries:
{
"credHelpers": {
"gcr.io": "gcloud",
"us.gcr.io": "gcloud",
"eu.gcr.io": "gcloud",
"asia.gcr.io": "gcloud",
"staging-k8s.gcr.io": "gcloud",
"marketplace.gcr.io": "gcloud"
}
}
Adding credentials for: us-ce
WARNING: us-ce is not a supported registry
gcloud credential helpers already registered correctly.
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ gcloud auth configure-docker us-central1-docker.pkg.dev
WARNING: Your config file at [/home/student_02_f6b847233541/.docker/config.json] contains these credential helper entries:
{
"credHelpers": {
"gcr.io": "gcloud",
"us.gcr.io": "gcloud",
"eu.gcr.io": "gcloud",
"asia.gcr.io": "gcloud",
"staging-k8s.gcr.io": "gcloud",
"marketplace.gcr.io": "gcloud"
}
}
Adding credentials for: us-central1-docker.pkg.dev
After update, the following will be written to your Docker config file located at [/home/student_02_f6b847233541/.docker/config.json]:
{
"credHelpers": {
"gcr.io": "gcloud",
"us.gcr.io": "gcloud",
"eu.gcr.io": "gcloud",
"asia.gcr.io": "gcloud",
"staging-k8s.gcr.io": "gcloud",
"marketplace.gcr.io": "gcloud",
"us-central1-docker.pkg.dev": "gcloud"
}
}
Do you want to continue (Y/n)? Y
Docker configuration file updated.
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ export PROJECT_ID=$(gcloud config get-value project)
cd ~/test
Your active configuration is: [cloudshell-9872]
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
node-app 0.2 8662f116ddc3 14 minutes ago 1.09GB
node-app 0.1 fc997911eb07 27 minutes ago 1.09GB
ubuntu latest 5a81c4b8502e 4 weeks ago 77.8MB
hello-world latest 9c7a54a9a43c 2 months ago 13.3kB
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker build -t us-central1-docker.pkg.dev/$PROJECT_ID/my-repository/node-app:0.2 .
[+] Building 0.4s (8/8) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 393B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/node:lts 0.3s
=> [1/3] FROM docker.io/library/node:lts@sha256:c85dc4392f44f5de1d0d72dd20a088a542734445f99bed7aa8ac895c706d370d 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 110B 0.0s
=> CACHED [2/3] WORKDIR /app 0.0s
=> CACHED [3/3] ADD . /app 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:8662f116ddc3f8fbf0ae3e9e16bf2ea691cacc6c6342d065c354733fa18d3864 0.0s
=> => naming to us-central1-docker.pkg.dev/qwiklabs-gcp-00-b963d48bc95a/my-repository/node-app:0.2 0.0s
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
node-app 0.2 8662f116ddc3 14 minutes ago 1.09GB
us-central1-docker.pkg.dev/qwiklabs-gcp-00-b963d48bc95a/my-repository/node-app 0.2 8662f116ddc3 14 minutes ago 1.09GB
node-app 0.1 fc997911eb07 28 minutes ago 1.09GB
ubuntu latest 5a81c4b8502e 4 weeks ago 77.8MB
hello-world latest 9c7a54a9a43c 2 months ago 13.3kB
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker push us-central1-docker.pkg.dev/$PROJECT_ID/my-repository/node-app:0.2
The push refers to repository [us-central1-docker.pkg.dev/qwiklabs-gcp-00-b963d48bc95a/my-repository/node-app]
0e30b1acba52: Pushed
fea73800b760: Pushed
b668ba7296ec: Pushed
dd96607f8903: Pushed
46cc0cc97ccb: Pushed
d66e0858bdee: Pushed
6a25221bdf24: Pushed
b578f477cd5d: Pushed
b298f9991a11: Pushed
c94dc8fa3d89: Pushed
0.2: digest: sha256:6a4fb39e8e604fa4e817ee4c3bf3d7f0dfd3d4d4a8f6f34211f3aa77f6588795 size: 2417
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
eaa665d80271 node-app:0.2 "docker-entrypoint.s…" 16 minutes ago Up 16 minutes 0.0.0.0:8080->80/tcp my-app-2
db70087920a9 node-app:0.1 "docker-entrypoint.s…" 22 minutes ago Up 22 minutes 0.0.0.0:4000->80/tcp my-app
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker stop $(docker ps -q)
docker rm $(docker ps -aq)
eaa665d80271
db70087920a9
eaa665d80271
db70087920a9
ceeb9f314192
c3429a31517a
006e4fd82211
18463f62ccd2
82154a06a2fc
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
us-central1-docker.pkg.dev/qwiklabs-gcp-00-b963d48bc95a/my-repository/node-app 0.2 8662f116ddc3 17 minutes ago 1.09GB
node-app 0.2 8662f116ddc3 17 minutes ago 1.09GB
node-app 0.1 fc997911eb07 30 minutes ago 1.09GB
ubuntu latest 5a81c4b8502e 4 weeks ago 77.8MB
hello-world latest 9c7a54a9a43c 2 months ago 13.3kB
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker rmi us-central1-docker.pkg.dev/$PROJECT_ID/my-repository/node-app:0.2
docker rmi node:lts
docker rmi -f $(docker images -aq) # remove remaining images
docker images
Untagged: us-central1-docker.pkg.dev/qwiklabs-gcp-00-b963d48bc95a/my-repository/node-app:0.2
Untagged: us-central1-docker.pkg.dev/qwiklabs-gcp-00-b963d48bc95a/my-repository/node-app@sha256:6a4fb39e8e604fa4e817ee4c3bf3d7f0dfd3d4d4a8f6f34211f3aa77f6588795
Error response from daemon: No such image: node:lts
Untagged: node-app:0.2
Deleted: sha256:8662f116ddc3f8fbf0ae3e9e16bf2ea691cacc6c6342d065c354733fa18d3864
Untagged: node-app:0.1
Deleted: sha256:fc997911eb07328452f98d376dcb73a736893c31d7a2f871b1944991732837a0
Untagged: ubuntu:latest
Untagged: ubuntu@sha256:0bced47fffa3361afa981854fcabcd4577cd43cebbb808cea2b1f33a3dd7f508
Deleted: sha256:5a81c4b8502e4979e75bd8f91343b95b0d695ab67f241dbed0d1530a35bde1eb
Deleted: sha256:59c56aee1fb4dbaeb334aef06088b49902105d1ea0c15a9e5a2a9ce560fa4c5d
Untagged: hello-world:latest
Untagged: hello-world@sha256:926fac19d22aa2d60f1a276b66a20eb765fbeea2db5dbdaafeb456ad8ce81598
Deleted: sha256:9c7a54a9a43cca047013b82af109fe963fde787f63f9e016fdc3384500c2823d
Deleted: sha256:01bb4fce3eb1b56b05adf99504dafd31907a5aadac736e36b27595c8b92f07f1
REPOSITORY TAG IMAGE ID CREATED SIZE
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker pull us-central1-docker.pkg.dev/$PROJECT_ID/my-repository/node-app:0.2
docker run -p 4000:80 -d us-central1-docker.pkg.dev/$PROJECT_ID/my-repository/node-app:0.2
curl http://localhost:4000
0.2: Pulling from qwiklabs-gcp-00-b963d48bc95a/my-repository/node-app
785ef8b9b236: Already exists
5a6dad8f55ae: Already exists
bd36c7bfe5f4: Already exists
4d207285f6d2: Already exists
e1c045e015f5: Already exists
7b238747a438: Already exists
332e7d92ba93: Already exists
7718d827325f: Already exists
0c3446603207: Already exists
0a9a9e6040a7: Already exists
Digest: sha256:6a4fb39e8e604fa4e817ee4c3bf3d7f0dfd3d4d4a8f6f34211f3aa77f6588795
Status: Downloaded newer image for us-central1-docker.pkg.dev/qwiklabs-gcp-00-b963d48bc95a/my-repository/node-app:0.2
us-central1-docker.pkg.dev/qwiklabs-gcp-00-b963d48bc95a/my-repository/node-app:0.2
1212b48b194616374a3d63f77c15fab70cc471245f4f80fa5980d02c64ad0416
curl: (52) Empty reply from server
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1212b48b1946 us-central1-docker.pkg.dev/qwiklabs-gcp-00-b963d48bc95a/my-repository/node-app:0.2 "docker-entrypoint.s…" 9 seconds ago Up 8 seconds 0.0.0.0:4000->80/tcp quizzical_cartwright
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
us-central1-docker.pkg.dev/qwiklabs-gcp-00-b963d48bc95a/my-repository/node-app 0.2 8662f116ddc3 18 minutes ago 1.09GB
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$ history
1 gcloud auth list
2 docker --version
3 docker images
4 docker ps
5 docker ps -a
6 docker run hello-world
7 docker images
8 docker ps
9 docker ps -a
10 docker images
11 docker ps
12 docker ps -a
13 docker ps --help
14 docker ps -o wide
15 docker ps wide
16 docker ps help
17 docker container -o wide
18 docker ps wide
19 docker ps -a
20 docker ps
21 docker images
22 docker run hello-world
23 docker ps
24 docker ps -a
25 docker run hello-world
26 docker ps -a
27 mkdir test ; cd test
28 vi Dockerfile
29 cat Dockerfile
30 vi Dockerfile
31 cat Dockerfile
32 docker build -t node-app:0.1 .
33 vi Dockerfile
34 docker build -t node-app:0.1 .
35 vi Dockerfile
36 vi app1
37 cp app1 app.js
38 ./app.js
39 ls -l
40 chmod +x app.js
41 ls -l
42 ./app.js
43 docker build -t node-app:0.1 .
44 vi Dockerfile
45 ls -l
46 docker build -t node-app:0.1 .
47 docker images
48 docker ps
49 docker ps -a
50 docker run -p 4000:80 --name my-app node-app:0.1
51 docker exec -it db70087920a9 bash
52 docker inspect db70087920a9
53 docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' db70087920a9
54 gcloud auth configure-docker us-ce
55 gcloud auth configure-docker us-central1-docker.pkg.dev
56 export PROJECT_ID=$(gcloud config get-value project)
57 cd ~/test
58 docker images
59 docker build -t us-central1-docker.pkg.dev/$PROJECT_ID/my-repository/node-app:0.2 .
60 docker images
61 docker push us-central1-docker.pkg.dev/$PROJECT_ID/my-repository/node-app:0.2
62 docker ps
63 docker stop $(docker ps -q)
64 docker rm $(docker ps -aq)
65 docker ps
66 docker images
67 docker rmi us-central1-docker.pkg.dev/$PROJECT_ID/my-repository/node-app:0.2
68 docker rmi node:lts
69 docker rmi -f $(docker images -aq) # remove remaining images
70 docker images
71 docker ps
72 docker pull us-central1-docker.pkg.dev/$PROJECT_ID/my-repository/node-app:0.2
73 docker run -p 4000:80 -d us-central1-docker.pkg.dev/$PROJECT_ID/my-repository/node-app:0.2
74 curl http://localhost:4000
75 docker ps
76 docker images
77 history
student_02_f6b847233541@cloudshell:~/test (qwiklabs-gcp-00-b963d48bc95a)$
No comments:
Post a Comment