cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
6573
Views
0
Helpful
8
Replies

ioxclient : error packaging docker style apps when tag is omitted.

havishwa
Cisco Employee
Cisco Employee

Hello all

With IOx 1.2 and ioxclient 1.2.1.0, you will be able to use a docker image and create an iox application from it. To do that, you will be using the "ioxclient docker package" command (https://developer.cisco.com/media/iox-dev-guide-11-15-16/ioxclient/ioxclient-reference/#commands-for-docker-workflow).

One of the caveats of this command is that you cannot use a "bare" image name as the parameter.

$ ioxclient docker package

NAME: package - Package an existing docker image as an IOx application USAGE: command package [command options] <docker_image> <project_dir>

What will NOT work (this causes a runtime panic):

$ ioxclient docker package alpine .

Workaround:

$ ioxclient docker package alpine:latest .

PS: Essentially, you cannot omit the ":<tag>" in the image name and it is mandatory.

szhang2 chandvensbalani

8 Replies 8

Steve Zhang
Cisco Employee
Cisco Employee

Thanks Harish. It helps.

It may apply for the docker app samples of docker-c-app, python-mods, and docker-cpp-app.

rmongeon
Level 1
Level 1

Greetings,

I've been trying to follow the DevNet lab, "Building an IOx Application with Docker". I'm at the point where I need to package my docker image using the command:
ioxclient docker package rmongeon/iox-test:latest .

When I do this I get:
------------------------------------------
Currently active profile : default
Command Name: docker-package
Using the package descriptor file in the project dir
Validating descriptor file package.yaml with package schema definitions
Parsing descriptor file..
Found schema version 2.2
Loading schema file for version 2.2
Validating package descriptor file..
File package.yaml is valid under schema version 2.2
Generating IOx package of type docker with layers as rootfs
Could not retrieve requested Docker image.
Unable to retrieve docker image
Error occurred : dial unix /var/run/docker.sock: connect: A socket operation encountered a dead network.
-------------------------------------------
I've followed the lab to the letter. The directory that I'm running the ioxclient command in is here:


C:\Users\robmo\CiscoLabs\Docker\IOx>dir
07/21/2019 09:48 AM 334 activation.json
07/18/2019 08:25 PM 134 Dockerfile
07/17/2019 08:04 PM 338 main.py
07/17/2019 08:06 PM 470 package.yaml
...
Here is my localhost' image listing:

C:\Users\robmo\CiscoLabs\Docker\IOx>docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
rmongeon/iox-test latest a6e8886646b1 2 hours ago 61.4MB
nginx 1.15 53f3fd8007f7 2 months ago 109MB
alpine 3.5 f80194ae2e0c 5 months ago 4MB

-What's not working here?

Rob Mongeon

"Could not retrieve requested Docker image.
Unable to retrieve docker image
Error occurred : dial unix /var/run/docker.sock: connect: A socket operation encountered a dead network."

 

Looks like you are using Windows development machine. I think in windows, docker client communicates with docker engine using tcp://<ip>:port, in which case you need to first initialize ioxclient docker client accordingly.

 

Check out the command

$ioxclient docker init

 

Once you configure ioxclient docker client with appropriate tcp url, ioxclient should be able talk to docker engine.

 

In case of linux and Mac this extra step is not needed, as the default docker client config of unix socket is used to talk to docker engine.

I do this:

C:\Users\robmo\CiscoLabs\Docker\IOx>ioxclient docker init
Enter the URI for the Docker daemon to use[unix:///var/run/docker.sock]: devnetsandbox-us-sjc.cisco.com:20198
Enter the API version that the target daemon is running[v1.22]:
Saving current configuration

 

------

and run:

C:\Users\robmo\CiscoLabs\Docker\IOx>ioxclient docker package rmongeon/iox-test:latest .
Currently active profile : default
Command Name: docker-package
Using the package descriptor file in the project dir
Validating descriptor file package.yaml with package schema definitions
Parsing descriptor file..
Found schema version 2.2
Loading schema file for version 2.2
Validating package descriptor file..
File package.yaml is valid under schema version 2.2
Generating IOx package of type docker with layers as rootfs
Could not retrieve requested Docker image.
Unable to retrieve docker image
Error occurred : Get http://devnetsandbox-us-sjc.cisco.com:20198/images/rmongeon/iox-test:latest/get: read tcp 10.0.0.251:57266->128.107.93.228:20198: wsarecv: An existing connection was forcibly closed by the remote host.

 

All my connections are live and on. It is indeed a fresh build of Win10Pro running the latest Docker and ioxclient.

 

 

 

package.yaml

descriptor-schema-version: "2.2"

info:
name: iox_docker_python_ll
description: "IOx Docker Python Web Learning Lab Application"
version: "1.0"
author-link: "http://www.cisco.com"
author-name: "Cisco Systems"

app:
cpuarch: "x86_64"
type: docker
resources:
profile: c1.small
network:
-
interface-name: eth0
ports:
tcp:
- 8000

startup:
rootfs: rootfs.tar
target: ["python3 main.py"]
------Dockerfile---
FROM alpine:3.5
RUN apk add --update \
python3
RUN pip3 install bottle
EXPOSE 8000
COPY main.py /main.py
CMD python3 /main.py
 
---- main
from bottle import route, run
from datetime import datetime

@route('/status/<device_id>')
def status(device_id):
return { "system": 1, "device": str(device_id) }

@route('/time')
def time():
current_time = datetime.now().isoformat(' ')
return {"system": 1, "datetime": current_time}

run(host='0.0.0.0', port=8000)
 
 

1. In case of Windows, you need to first enable tcp server on docker engine. In docker settings, select the last check box as shown here.

 

05_18_57.jpg

 

2. After that, you need to setup ioxclient docker config using the command like below.

05_18_36.jpg

 

3. Now your ioxclient can start communicating with docker engine.

4. You can package docker image using ioxclient 

$ ioxclient docker package rmongeon/iox-test:latest .

Hope this helps

This worked! It's 2 additional steps not mentioned in the lab but the trick was to:

- create your image tagging it:

PS > docker build -t robmo/iox-test .

 

Fix your Win 10 Docker client settings:

open Docker in system tray -> Settings ->
- Check the Expose daemon on tcp://localhost:2375 without TLS
- rt. click -> Restart Docker

 

Package it up from a CMD prompt:

ioxclient docker package robmo/iox-test:latest .

 

And get the result:

Generating IOx Package..
Package docker image robmo/iox-test:latest at C:\Users\robmo\CiscoLabs\Docker\IOx\package.tar

 

Thanks!

-Rob

 

 

Ok, it seems the packaging and creation of the Docker image was fine but now deploying it from ioxclient is an issue. With my IOX CAF lab running and connected to the VPN if I run the following command I get exceptions:

>ioxclient application install pybreaker package.tar

and get:

 

Sending request to install the app
Following layers are missing on the device: "c0519570f3a4b03cb8eb1350e81a2230411e70147452afd12e385bce8517135f", "7039ee93a941a33e6078451404f3e50ed7d3a9635c48fa956a00b799e1e012af", "c62a00b8e2425a8bb52b1f80f5a33fe382a15bfab9dbe1e4e35835f0c5f95a8c", "ad5eb23a8a953a47dd43d2afcbaedb388cbca727da66fc48371e764d16a16598", "1bfeebd65323b8ddf5bd6a51cc7097b72788bc982e9ab3280d53d3c613adffa7", "622ce7163ec3c52d0c91bc1d71e90918298eb79a629991fc1a0bf5ae9ca06714", "75234101a9a62ea85aa24e7521a3b2ed626e21db4ff36dad36e91703489bcb0c"
Installing layer C:\Users\robmo\CiscoLabs\Docker\Workspace\iox-docker-python-web\20190803144218129474500\iox_layers\c0519570f3a4b03cb8eb1350e81a2230411e70147452afd12e385bce8517135f.tar.gz
Error. Server returned 500
{
"description": "Error while adding the layer: [Errno 2] No such file or directory: u'/software/tmp/tmpUEEHAt/2cbd96a22a2d0dc33a6179ce24f76169ac918c6afa306b7acb11e9c8e890eaa1/layer.tar'",
"errorcode": -1,
"message": "Error while adding the layer"
}

---------------------------------

While this doesn't work from my Win10 dev box, I can actually go to the lab at https://10.10.20.51:8443/admin and use the webgui to upload the package file. The command to activate the package works fine though:

C:\Users\robmo\CiscoLabs\Docker\Workspace\iox-docker-python-web>ioxclient app activate --payload activation.json pybreaker
Currently active profile : default
Command Name: application-activate
Payload file : activation.json. Will pass it as application/json in request body..
App pybreaker is Activated

 

It looks as if there are dependencies on the device that aren't there when deploying via ioxclient.

 

-rob