lavie / runlike

Given an existing docker container, prints the command line necessary to run a copy of it.
Other
1.99k stars 118 forks source link

Crashes on JSON parsing #86

Closed fatso83 closed 3 years ago

fatso83 commented 3 years ago

It does not seem to like the output from my inspect command ... Not sure if this is down to the old Docker version (19.03.6) running on the node I captured the output from?

$ cat out.txt | docker run --rm -v /var/run/docker.sock:/var/run/docker.sock assaflavie/runlike --stdin
Traceback (most recent call last):
  File "/usr/bin/runlike", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3.8/site-packages/runlike/runlike.py", line 37, in main
    cli()
  File "/usr/lib/python3.8/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.8/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/runlike/runlike.py", line 31, in cli
    ins.set_facts(raw_json)
  File "/usr/lib/python3.8/site-packages/runlike/inspector.py", line 40, in set_facts
    self.facts = loads(raw_json)
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

out.txt

lavie commented 3 years ago

Trying adding -i to docker run

fatso83 commented 3 years ago

That was it 🙈

docker run --name=root_myapp-fpm_1 --hostname=4551cbfdb140 
--env=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 
--env='PHPIZE_DEPS=autoconf         dpkg-dev        file        g++         gcc         libc-dev        make        pkg-config      re2c' 
--env=PHP_INI_DIR=/usr/local/etc/php --env='PHP_EXTRA_CONFIGURE_ARGS=--enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --disable-cgi' 
--env='PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2' 
--env='PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2' --env='PHP_LDFLAGS=-Wl,-O1 -Wl,--hash-style=both -pie' 
--env='GPG_KEYS=A917B1ECDA84AEC2B568FED6F50ABC807BD5DCD0 528995BFEDFBA7191D46839EF9BA0ADA31CBD89E 1729F83938DA44E27BA0F4D3DBDB397470D12172' 
--env=PHP_VERSION=7.1.30 --env=PHP_URL=https://www.php.net/get/php-7.1.30.tar.xz/from/this/mirror 
--env=PHP_ASC_URL=https://www.php.net/get/php-7.1.30.tar.xz.asc/from/this/mirror 
--env=PHP_SHA256=6310599811536dbe87e4bcf212bf93196bdfaff519d0c821e4c0068efd096a7c 
--env=PHP_MD5= 
--volumes-from=7713d5314f5812be835f23a69a5038c491b1eed8acbc7c05163db776caf9e294:rw 
--network=root_default 
--workdir=/var/www/html 
-p 10.135.17.193:9000:9000 
--restart=always 
--label='com.docker.compose.container-number=1' 
--label='com.docker.compose.oneoff=False' --label='com.docker.compose.project=root' 
--label='com.docker.compose.version=1.8.0' 
--label='com.docker.compose.service=myapp-fpm' 
--label='com.docker.compose.config-hash=df8cddcbc8c7112eb8b18b2c1637146b8784597453297142fa56cd69e4ef8ff3' 
--runtime=runc 
--detach=true 
my.register.aws/myapp-fpm:latest