Catalyst9300의 Docker 애플리케이션 호스팅을 사용해보십시오.
소개
IOS XE 16.12부터 Docker 애플리케이션 호스팅이 지원되었습니다.
조금 혼란 스럽지만 IR829/IR809 등에서 지원되는 Cisco IOx Docker 스타일 앱과 다릅니다. 이쪽은 Docker 형식의 이미지를 LXC로 동작시킨다고 하는 흑마술적인 실장이 되어 있습니다.
[Qiita] Cisco IOx Docker 유형 앱을 사용해 보세요.
htps : // 이 m / 테츠사 t / ms / 8576에 b0f80에 50746cf7d
전제
이 기사에서는 다음 환경을 사용합니다.
Docker 응용 프로그램을 배포하는 환경에는 다음 DevNet Sandbox IOS XE on Catalyst 9000 16.12 EFT Code을 사용했습니다.

Docker 애플리케이션을 빌드하는 환경에는 다음을 사용했습니다.
이 기사에서는 다음 환경을 사용합니다.
Docker 응용 프로그램을 배포하는 환경에는 다음
DevNet Sandbox IOS XE on Catalyst 9000 16.12 EFT Code을 사용했습니다.
Docker 애플리케이션을 빌드하는 환경에는 다음을 사용했습니다.
Docker 애플리케이션 빌드
Docker 응용 프로그램을 빌드하는 별도의 환경을 제공합니다.
적당한 작업 디렉토리에 Hello World! 라고 돌려줄 뿐의 샘플 어플리케이션을 작성합니다.
hello.gopackage main
import (
"fmt"
"log"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello World!")
})
if err := http.ListenAndServe(":8080", nil); err != nil {
log.Fatal("ListenAndServe failed.", err)
}
}
모두 사랑하는 Multi Stage Build에서 Docker 이미지를 최대한 줄입니다.
필수는 아니지만 DevNet Sandbox의 원격 환경에 있는 Catalyst에 Docker 이미지를 복사하는 데 시간이 걸리기 때문입니다.
DockerfileFROM golang:latest as builder
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64
COPY hello.go /go/src/hello.go
WORKDIR /go/src
RUN go build -o app
FROM alpine
RUN apk add --no-cache ca-certificates
COPY --from=builder /go/src/app /app
EXPOSE 8080
ENTRYPOINT ["/app"]
먼저 응용 프로그램이 로컬 환경에서 제대로 작동하는지 확인합니다.
Docker 이미지를 빌드합니다.
$ docker build -t hello .
Docker 컨테이너를 시작합니다.
$ docker run -d -p 8080:8080 hello
액세스하면 Hello Wold! 라고 반환합니다.
$ curl localhost:8080
그런 다음 Docker 이미지를 Tar 형식으로 출력합니다.
$ docker save hello -o hello.tar
Catalyst9300 애플리케이션 호스팅 구성
여기에서 앞으로의 작업은 DevNet Sandbox 환경에 VPN 연결하여 실시합니다.
Catalyst 측에서 SCP를 활성화합니다. 사용자 자격 증명 정보는 SSH 용으로 제공되는 developer/C1sco12345를 그대로 사용합니다.
cat9k(config)#ip scp server enable
VPN 연결된 PC에서 Tar 형식 Docker 이미지를 SCP로 복사합니다.
$ scp hello.tar [email protected]:flash:/hello.tar
Catalyst에서 애플리케이션 호스팅을 위한 설정을 구성합니다.
Docker 컨테이너의 실행 환경에는 관리 인터페이스와 동일한 서브넷(10.10.20.0/24) 범위 내의 주소를 할당합니다.
이번 환경에서는 컨테이너의 실행 환경에 게이트웨이는 필요하지 않습니다만, 통상은 필요하므로 만약을 위해 할당해 둡니다.
Docker 컨테이너에 할당할 리소스와 Docker 컨테이너를 시작하는 옵션과 리소스도 여기에서 설정합니다.
app-hosting appid HELLO
app-vnic management guest-interface 0
guest-ipaddress 10.10.20.101 netmask 255.255.255.0
app-default-gateway 10.10.20.254 guest-interface 0
app-resource docker
run-opts "-p 8080:8080"
app-resource profile custom
cpu 7400
memory 1024
Docker 애플리케이션을 설치합니다.
cat9k#app-hosting install appid HELLO package flash:hello.tar
Installing package 'flash:hello.tar' for 'HELLO'. Use 'show app-hosting list' for progress.
이 때의 상태를 확인하면 DEPLOYED가 됩니다.
cat9k#show app-hosting list
App id State
---------------------------------------------------------
HELLO DEPLOYED
Docker 애플리케이션을 활성화합니다.
cat9k#app-hosting activate appid HELLO
HELLO activated successfully
Current state is: ACTIVATED
이 때의 상태를 확인하면 ACTIVATED가 됩니다.
cat9k#show app-hosting list
App id State
---------------------------------------------------------
HELLO ACTIVATED
Docker 애플리케이션을 시작합니다.
cat9k#app-hosting start appid HELLO
HELLO started successfully
Current state is: RUNNING
이 때의 상태를 확인하면 RUNNING가 됩니다.
cat9k#show app-hosting list
App id State
---------------------------------------------------------
HELLO RUNNING
Docker 애플리케이션에 대해 자세히 알아보세요.
cat9k#show app-hosting detail
App id : HELLO
Owner : iox
State : RUNNING
Application
Type : docker
Name : hello
Version : latest
Description :
Path : flash:hello.tar
Activated profile name : custom
Resource reservation
Memory : 1024 MB
Disk : 10 MB
CPU : 7400 units
VCPU : 1 units
Attached devices
Type Name Alias
---------------------------------------------
serial/shell iox_console_shell serial0
serial/aux iox_console_aux serial1
serial/syslog iox_syslog serial2
serial/trace iox_trace serial3
Network interfaces
---------------------------------------
eth0:
MAC address : 52:54:dd:6a:96:c5
IPv4 address : 10.10.20.101
Network name : mgmt-bridge100
Docker
------
Run-time information
Command :
Entry-point : /app
Run options in use : -p 8080:8080
Application health information
Status : 0
Last probe error :
Last probe output :
동작 확인
마지막으로 응용 프로그램이 제대로 작동하는지 확인해보십시오. 이 테스트는 DevBox VM에서 수행하십시오. DevNet Sandbox의 사양상, VPN 접속한 PC로부터 가도 실패합니다.
Devbox VM에 SSH 연결한 다음 curl로 액세스합니다.
[developer@devbox ~]$ curl 10.10.20.101:8080
Hello World!
Hello Wold! 라고 돌아오면 성공입니다.
궁리에 따라 여러가지 편리한 구조를 만들 수 있을 것 같습니다.
오시마
Reference
이 문제에 관하여(Catalyst9300의 Docker 애플리케이션 호스팅을 사용해보십시오.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/tetsusat/items/ec11ddb70197b24175e8
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello World!")
})
if err := http.ListenAndServe(":8080", nil); err != nil {
log.Fatal("ListenAndServe failed.", err)
}
}
FROM golang:latest as builder
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64
COPY hello.go /go/src/hello.go
WORKDIR /go/src
RUN go build -o app
FROM alpine
RUN apk add --no-cache ca-certificates
COPY --from=builder /go/src/app /app
EXPOSE 8080
ENTRYPOINT ["/app"]
$ docker build -t hello .
$ docker run -d -p 8080:8080 hello
$ curl localhost:8080
$ docker save hello -o hello.tar
여기에서 앞으로의 작업은 DevNet Sandbox 환경에 VPN 연결하여 실시합니다.
Catalyst 측에서 SCP를 활성화합니다. 사용자 자격 증명 정보는 SSH 용으로 제공되는
developer/C1sco12345를 그대로 사용합니다.cat9k(config)#ip scp server enable
VPN 연결된 PC에서 Tar 형식 Docker 이미지를 SCP로 복사합니다.
$ scp hello.tar [email protected]:flash:/hello.tar
Catalyst에서 애플리케이션 호스팅을 위한 설정을 구성합니다.
Docker 컨테이너의 실행 환경에는 관리 인터페이스와 동일한 서브넷(
10.10.20.0/24) 범위 내의 주소를 할당합니다.이번 환경에서는 컨테이너의 실행 환경에 게이트웨이는 필요하지 않습니다만, 통상은 필요하므로 만약을 위해 할당해 둡니다.
Docker 컨테이너에 할당할 리소스와 Docker 컨테이너를 시작하는 옵션과 리소스도 여기에서 설정합니다.
app-hosting appid HELLO
app-vnic management guest-interface 0
guest-ipaddress 10.10.20.101 netmask 255.255.255.0
app-default-gateway 10.10.20.254 guest-interface 0
app-resource docker
run-opts "-p 8080:8080"
app-resource profile custom
cpu 7400
memory 1024
Docker 애플리케이션을 설치합니다.
cat9k#app-hosting install appid HELLO package flash:hello.tar
Installing package 'flash:hello.tar' for 'HELLO'. Use 'show app-hosting list' for progress.
이 때의 상태를 확인하면
DEPLOYED가 됩니다.cat9k#show app-hosting list
App id State
---------------------------------------------------------
HELLO DEPLOYED
Docker 애플리케이션을 활성화합니다.
cat9k#app-hosting activate appid HELLO
HELLO activated successfully
Current state is: ACTIVATED
이 때의 상태를 확인하면
ACTIVATED가 됩니다.cat9k#show app-hosting list
App id State
---------------------------------------------------------
HELLO ACTIVATED
Docker 애플리케이션을 시작합니다.
cat9k#app-hosting start appid HELLO
HELLO started successfully
Current state is: RUNNING
이 때의 상태를 확인하면
RUNNING가 됩니다.cat9k#show app-hosting list
App id State
---------------------------------------------------------
HELLO RUNNING
Docker 애플리케이션에 대해 자세히 알아보세요.
cat9k#show app-hosting detail
App id : HELLO
Owner : iox
State : RUNNING
Application
Type : docker
Name : hello
Version : latest
Description :
Path : flash:hello.tar
Activated profile name : custom
Resource reservation
Memory : 1024 MB
Disk : 10 MB
CPU : 7400 units
VCPU : 1 units
Attached devices
Type Name Alias
---------------------------------------------
serial/shell iox_console_shell serial0
serial/aux iox_console_aux serial1
serial/syslog iox_syslog serial2
serial/trace iox_trace serial3
Network interfaces
---------------------------------------
eth0:
MAC address : 52:54:dd:6a:96:c5
IPv4 address : 10.10.20.101
Network name : mgmt-bridge100
Docker
------
Run-time information
Command :
Entry-point : /app
Run options in use : -p 8080:8080
Application health information
Status : 0
Last probe error :
Last probe output :
동작 확인
마지막으로 응용 프로그램이 제대로 작동하는지 확인해보십시오. 이 테스트는 DevBox VM에서 수행하십시오. DevNet Sandbox의 사양상, VPN 접속한 PC로부터 가도 실패합니다.
Devbox VM에 SSH 연결한 다음 curl로 액세스합니다.
[developer@devbox ~]$ curl 10.10.20.101:8080
Hello World!
Hello Wold! 라고 돌아오면 성공입니다.
궁리에 따라 여러가지 편리한 구조를 만들 수 있을 것 같습니다.
오시마
Reference
이 문제에 관하여(Catalyst9300의 Docker 애플리케이션 호스팅을 사용해보십시오.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/tetsusat/items/ec11ddb70197b24175e8
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
[developer@devbox ~]$ curl 10.10.20.101:8080
Hello World!
Reference
이 문제에 관하여(Catalyst9300의 Docker 애플리케이션 호스팅을 사용해보십시오.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/tetsusat/items/ec11ddb70197b24175e8텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)