ANSIBLE VERSION
2.4.1.0
OS / ENVIRONMENT
centos 7 in vagrant
SUMMARY
install docker script
function docker_install() {
echo "docker install"
if [ ${sysOS} == "Linux" ]
then
if [ ! -f /tmp/install_docker_flag ]; then
rm -f /var/run/docker.sock
tar zxvf ${DOCKER_ENGINE_DIR}/${DOCKER_FILE}.tar.gz
mv ${DOCKER_FILE}/* /usr/local/bin
tar zxvf ${DOCKER_ENGINE_DIR}/${DOCKER_COMPOSE_FILE}.tar.gz
mv ${DOCKER_COMPOSE_FILE}/* /usr/local/bin/docker-compose
# echo '{"insecure-registries":["'${PRIVATE_REGISTRY}'"]}' > /etc/docker/daemon.json
mkdir -p /etc/docker
echo '{"registry-mirrors": ["http://'${PRIVATE_REGISTRY}'"], "insecure-registries" : [ "'${PRIVATE_REGISTRY}'"] }' > /etc/docker/daemon.json
rm -fr ${DOCKER_FILE}
rm -fr ${DOCKER_COMPOSE_FILE}
echo 'success' > /tmp/install_docker_flag
else
echo 'already installed docker'
fi
else
echo "this is "${sysOS}
exit 1
fi
}
This just copy dockerd binary to /usr/local/bin
start docker
- name: start docker
shell: /usr/local/bin/dockerd >/dev/null 2>&1 &
# command: sh {{ start_docker_script }}
logs
- But script
docker load < ${DOCKER_IMAGES_DIR}/${packages['registry']}
inTASK [registry : Install registry]
, complain docker not found. - After ansible failed, I enter that vm, confirmed dockerd was not running.
- I also tried to start
dockerd
by a script , nether work. - I enter vagrant and have confirmed all files copied successful .
- In vagrant vm, directly run
/usr/local/bin/dockerd >/dev/null 2>&1 &
is working
TASK [common : Install docker] ********************************************************************************
changed: [host02]
changed: [host01]
TASK [common : start docker] **********************************************************************************
changed: [host02]
changed: [host01]
PLAY [registry] ***********************************************************************************************
TASK [Gathering Facts] ****************************************************************************************
ok: [host01]
TASK [registry : Install registry] ****************************************************************************
fatal: [host01]: FAILED! => {
"changed": true,
"cmd": [
"sh",
"/data/bidspy-yychen/dist/scripts/install_registry.sh"
],
"delta": "0:00:00.045283",
"end": "2017-11-10 03:28:33.555247",
"failed": true,
"rc": 125,
"start": "2017-11-10 03:28:33.509964"
}
STDOUT:
/data/bidspy-yychen/dist/scripts
/data/bidspy-yychen/dist
STDERR:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
MSG:
non-zero return code