Hopefully this is an easy question, but please use kid gloves, because my container knowledge is zero thus far.
I am trying to provide an older version of a binary/package on Ubuntu 20.04, by using a 16.04 lxc container. Here are my steps for standing up my container.
$ multipass launch focal -n lixc ; multipass shell lixc
$ lxd init
$ lxc launch ubuntu:16.04 $lxcname ; lxc shell $lxcname
# apt update ; apt -y dist-upgrade ; apt -y install $myapp
$ lxd init --dump
config: {}
networks: []
storage_pools:
- config:
source: /var/snap/lxd/common/lxd/storage-pools/default
description: ""
name: default
driver: dir
profiles:
- config: {}
description: Default LXD profile
devices:
eth0:
name: eth0
nictype: macvlan
parent: enp0s2
type: nic
root:
path: /
pool: default
type: disk
name: default
I used the dir storage pool, no bridged networking, and more or less the defaults where possible.
The goal is to have a deployable container, with no networking requirements, to just run on a host system and take data in and spit data out from the package that I installed in the container.
I’ve got the container up and running with the package(s) I need, but I’m trying to figure out how to work with the container’s binary from the host system.
What I’m trying to do:
$ myapp $localinfile > $localoutfile
Ive tried using
$ lxc exec $lxcname $myapp $localinfile > $localoutfile
and
$ lxc-execute -n $lxcname $myapp $localinfile > $localoutfile
I then tried to pass through a working directory for in/out files.
$ lxc config device add $lxcname dir1 disk source=/tmp/passthru/ path=/passthru
$ lxc exec $lxcname $appname /passthru/$infile > /passthru/$outfile
-bash: /passthru/$outfile: No such file or directory #this makes sense, I'll try to change output to host dir
$ lxc exec $lxcname '$appname /passthru/$infile' > /tmp/passthru/$outfile #no output, it zeros out the $infile oddly enough, so *something* is happening
$ lxc exec $lxcname $appname /passthru/$infile #this prints a bunch of output, because the outfile is a png image, so this appears to be working.
If I shell into the container using `lxc shell $lxcname, I can then cd to /passthru and run the command like normal $myapp $localinfile > $localoutfile and it runs just fine.
This is the same for both the root user, which is the default shell user, and if I su to the Ubuntu user.
The passthru directory inside the container is owned by nobody:nogroup, despite the directory in the host being owned by ubuntu:ubuntu, ubuntu being the default user in the vm I’m using to test lxc on.
I have the passthru directory 777’d.
I tried specifying the uid to run as (1000), and tried forcing a non-interactive terminal, and also turned on the debug flag, but I’m not entirely sure how to figure out which rabbit hole to go down.
Linking pastebin of debug output in hopes someone can easily eyeball what I’m missing.
I imagine it’s some sort of logical disconnect in my mind having not dealt with containers, so hopefully this can demystify that for me.
TIA