docker: how to restart containers from files from /var/lib/docker/containers - docker

I have updated my distro from 13.04 to 13.10 and had a bunch of running containers. the container files are still in /var/lib/docker/container however I can not start these:
$ sudo docker start 7ef2b26aa60d70d9167571dcc55502eee0c9f80ad7601bacc8a047ca1b28be65
Error: No such container: 7ef2b26aa60d70d9167571dcc55502eee0c9f80ad7601bacc8a047ca1b28be65
2014/03/25 05:18:14 Error: failed to start one or more containers
$ sudo tail /var/log/upstart/docker.log
2014/03/25 05:11:19 POST /v1.10/images/create?fromImage=7ef2b26aa60d70d9167571dcc55502eee0c9f80ad7601bacc8a047ca1b28be65&tag=
[/var/lib/docker|5227412d] +job pull(7ef2b26aa60d70d9167571dcc55502eee0c9f80ad7601bacc8a047ca1b28be65, )
HTTP code: 404
[/var/lib/docker|5227412d] -job pull(7ef2b26aa60d70d9167571dcc55502eee0c9f80ad7601bacc8a047ca1b28be65, ) = ERR (1)
2014/03/25 05:18:14 POST /v1.10/containers/7ef2b26aa60d70d9167571dcc55502eee0c9f80ad7601bacc8a047ca1b28be65/start
[/var/lib/docker|5227412d] +job start(7ef2b26aa60d70d9167571dcc55502eee0c9f80ad7601bacc8a047ca1b28be65)
No such container: 7ef2b26aa60d70d9167571dcc55502eee0c9f80ad7601bacc8a047ca1b28be65
[/var/lib/docker|5227412d] -job start(7ef2b26aa60d70d9167571dcc55502eee0c9f80ad7601bacc8a047ca1b28be65) = ERR (1)
[error] server.go:950 Error: No such container: 7ef2b26aa60d70d9167571dcc55502eee0c9f80ad7601bacc8a047ca1b28be65
[error] server.go:85 HTTP Error: statusCode=404 No such container: 7ef2b26aa60d70d9167571dcc55502eee0c9f80ad7601bacc8a047ca1b28be65
debug log from docker startup
[debug] runtime.go:300 Cannot load container 7ef2b26aa60d70d9167571dcc55502eee0c9f80ad7601bacc8a047ca1b28be65 because it was created with another graph driver.
inspecting driver which this container was created with:
$ cd /var/lib/docker/containers/7ef2b26aa60d70d9167571dcc55502eee0c9f80ad7601bacc8a047ca1b28be65
$ cat ./config.json | grep -o Driver.*\",
Driver":"aufs","ExecDriver":"lxc-0.9.0",
is there any way to recover these?

Turns out after updating aufs was uninstalled. reinstalling like so:
sudo apt-get update
sudo apt-get install linux-image-extra-`uname -r`
fixes issue!

Related

Install AWX 17.1 and Docker-Compose 1.29.2 for CentOS7

My Server:
Virtual hardware: 2 vCPU / 4 Go
OS: CentOS Linux release 7.9.2009
Docker version 20.10.9
Docker Compose version 1.29.2 --> 2 installation methods
Ansible 2.9.25-1
libselinux-python3
python3-pip / pip 21.3.1
Python 2.7.5
Python 3.6.8
2 installation methods of Docker Compose:
by download from github:
# cp docker-compose-Linux-x86_64-1.29.2 /usr/local/bin/docker-compose
by PIP:
# pip3 install docker-compose --proxy "http://user:pass#proxy:port"
I try to install AWX 17.1.0 to my server.
If I use method 2 then the AWX installation works.
Otherwise if I use method 1 then AWX installation fails :
[root#myserver ~]# cp docker-compose-Linux-x86_64-1.29.2 /usr/local/bin/docker-compose
[root#myserver ~]# cd /awx-17.1.0/installer/
[root#myserver installer]# ansible-playbook -i inventory install.yml
(...)
TASK [local_docker : Remove AWX containers before migrating postgres so that the old postgres container does not get used] ***
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Unable to load docker-compose. Try `pip install docker-compose`. Error: Traceback (most recent call last):\n File \"/tmp/ansible_docker_compose_payload_ad5z56ir/ansible_docker_compose_payload.zip/ansible/modules/cloud/docker/docker_compose.py\", line 482, in <module>\nModuleNotFoundError: No module named 'compose'\n"}
...ignoring
TASK [local_docker : Run migrations in task container] *************************
changed: [localhost]
TASK [local_docker : Start the containers] *************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Unable to load docker-compose. Try `pip install docker-compose`. Error: Traceback (most recent call last):\n File \"/tmp/ansible_docker_compose_payload_1h9rln6h/ansible_docker_compose_payload.zip/ansible/modules/cloud/docker/docker_compose.py\", line 482, in <module>\nModuleNotFoundError: No module named 'compose'\n"}
(...)
I am comparing the files between the 2 methods:
By method 1 (github), 1 file only:
/usr/local/bin/docker-compose --> size : 12737304
By method 2 (pip):
/usr/local/bin/docker-compose --> size : 215
/usr/local/lib/python3.6/site-packages/compose/*
/usr/local/lib/python3.6/site-packages/docker_compose-1.29.2.dist-info/*
I don't understand why such a difference. I think this is the cause of my installation problem.
Therefore, I am looking for the way to install Docker Compose from Github as if the installation is done as per PIP.

installed the docker from binaries + docker startup

we installed the docker from binaries as the following ( according to https://docs.docker.com/engine/install/binaries/ )
wget https://download.docker.com/linux/static/stable/x86_64/docker-17.03.0-ce.tgz
--2020-05-06 20:39:22-- https://download.docker.com/linux/static/stable/x86_64/docker-17.03.0-ce.tgz
Resolving download.docker.com (download.docker.com)... 13.225.249.16, 13.225.249.45, 13.225.249.106, ...
Connecting to download.docker.com (download.docker.com)|13.225.249.16|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 27816900 (27M) [application/x-tar]
Saving to: ‘docker-17.03.0-ce.tgz’
100%[===================================================================================================================================================>] 27,816,900 4.76MB/s in 3.7s
2020-05-06 20:39:26 (7.11 MB/s) - ‘docker-17.03.0-ce.tgz’ saved [27816900/27816900]
now we tar it
tar xzvf docker-17.03.0-ce.tgz
docker/
docker/docker-containerd-ctr
docker/docker-proxy
docker/docker
docker/docker-containerd
docker/dockerd
docker/docker-init
docker/docker-containerd-shim
docker/docker-runc
the files after untar
# ls
docker docker-17.03.0-ce.tgz hsperfdata_root stable
cd docker/
# ls
docker docker-containerd docker-containerd-ctr docker-containerd-shim dockerd docker-init docker-proxy docker-runc
now we need to start the dockerd
but how to start it
we try y
/tmp/docker/dockerd
Failed to connect to containerd. Please make sure containerd is installed in your PATH or you have specified the correct address. Got error: exec: "docker-containerd": executable file not found in $PATH
so where we are wrong here ?
First you need to download and run containerd from containerd,
start it containerd& and then run dockerd &, after that you can try it docker run hello-world
It is not recommended way, better install it from repository with selinux or apparmor profiles.

Can't apply AppArmor profile on container: "no such file or directory"

I am trying to apply the following simple AppArmor profile:
#include <tunables/global>
profile docker-profile flags=(attach_disconnected,mediate_deleted) {
#include <abstractions/base>
#network,
#capability,
#file,
#umount,
#ptrace,
#mount,
pivot_root,
}
When I run docker run -it --rm --security-opt apparmor=docker-profile alpine I get the following error:
docker: Error response from daemon: invalid header field value "oci
runtime error: container_linux.go:247: starting container process
caused \"process_linux.go:359: container init caused \\"apparmor
failed to apply profile: no such file or directory\\"\"\n".
I tried to reinstall it (based on suggestions here):
rm -rf /etc/apparmor*
apt install apparmor --reinstall
service apparmor restart
service docker restart
It didn't help, I am still getting the same error.
Any suggestion what can be the reason and how to solve it ?
I needed to register the profile by running apparmor_parser -r -W docker.profile.
More information can be found here:
https://docs.docker.com/engine/security/apparmor/
sudo apt-get purge apparmor apparmor-profiles apparmor-utils
sudo apt-get install apparmor-utils apparmor-profiles apparmor-profiles-extra vim-addon-manager
reboot

Error processing tar file (exit status 1): unexpected EOF when building with docker-compose while data directory exists

My docker-compose.yml looks like this:
version: '3'
services:
phab:
build:
context: .
args:
- PHAB_BASE_URI=https://phab.example.com
- PHAB_REPO_PATH=/var/repo
- PHAB_TIMEZONE=Europe/Berlin
- PHP_POST_MAX_SIZE=32MB
ports:
- "127.0.0.1:8012:80"
volumes:
- ./.data/repos:/var/repo
- ./.data/mysql:/var/lib/mysql/
If I try to rebuild after I started the container, I get
$ docker-compose build
Building phab
ERROR: Error processing tar file(exit status 1): unexpected EOF
This appears to be due to the .data directory. The only "cure" I found was either deleting the directory or moving it outside of the project directory. Renaming the directory to eg. .data1 does not fix it.
$ sudo mv .data .data1
$ docker-compose build
Building phab
ERROR: Error processing tar file(exit status 1): unexpected EOF
$ sudo mv .data1 ..
$ docker-compose build
Building phab
Step 1/27 : FROM tutum/lamp:latest
---> 3d49e175ec00
Step 2/27 : RUN apt-get update && apt-get install -y php5-curl php5-mysqlnd php5-gd python3-pygments
---> Using cache
[ ... ]
I am using docker-compose 1.18.0, build 8dd22a9 abd Docker 18.06.0-ce, build 0ffa825 on Debian 9.5.
I have seen the question Docker ERROR: Error processing tar file(exit status 1): unexpected EOF. However just flushing the /var/lib/docker directory does not appear as an option to me. Pruning unused images and even removing the base image before the build does not fix the issue.
I had the same issue. The following steps solved it:
1.) Stop Docker Service.
systemctl stop docker
2.) Backup /var/lib/docker.
3.) Remove /var/lib/docker.
sudo rm -rf /var/lib/docker
4.) Start Docker Service.
systemctl start docker
Try upgrading to 18.09 which was just released yesterday. The "unexpected EOF" during a build looks like a known issue with 18.06: https://github.com/moby/moby/pull/37771
remove files generated by other container, like "db_data", "mysql_data", etc

Unable to install chef-server on docker container

I am unable to install chef-server (chef-server-core_12.0.8-1_amd64.deb) over a docker container (Ubuntu 14.04 x86_64).
When running chef-server-ctl reconfigure it fails with following error:
Error executing action run on resource 'execute[/opt/opscode/bin/private-chef-ctl start rabbitmq]'
Mixlib::ShellOut::ShellCommandFailed
Expected process to exit with [0], but received '1'
---- Begin output of /opt/opscode/bin/private-chef-ctl start rabbitmq ----
STDOUT: warning: rabbitmq: unable to open supervise/ok: file does not exist
STDERR:
---- End output of /opt/opscode/bin/private-chef-ctl start rabbitmq ----
Ran /opt/opscode/bin/private-chef-ctl start rabbitmq returned 1
NOTE: Before starting installation , I have done following steps inside the container:
dpkg-divert --local --rename --add /sbin/initctl
ln -sf /bin/true /sbin/initctl
sysctl -w kernel.shmmax=17179869184
Is there any other work-around to get chef-server up on docker container.

Resources