docker容器启动运行

2017/04/25 docker

docker容器启动运行

运行docker容器

docker run -i -t -v /data/www/dedecms_hiapk_com/:/data/wwwroot/cms.hiapk.com/webroot -p 8003:80 --name dedecms_hiapk_com 172.17.163.105:8500/online/cms.hiapk.com /data/start.sh
参数说明:
-i -t交互模式
-p 端口映射 宿主机:容器
--name 容器命名
-v 宿主机目录挂载到容器
docker run -i -t -v /data/www/data_php5.4/sjdedecms_manager91/:/data/wwwroot/ -p 8601:80 --name test.manager.91.com 172.17.163.105:8500/online/base_nginx_1.2.2_php_5.4.41

以后端模式运行

$ docker run -d -p 80:80 my_image /usr/local/nginx/sbin/nginx -g ‘daemon off;’

交互模式

docker run -i -t –rm -p 80:80 nginx

If you need to write a starter script for a single executable, you can ensure that the final executable receives the Unix signals by using exec and gosu commands:

#!/bin/bash
set -e

if [ "$1" = 'postgres' ]; then
    chown -R postgres "$PGDATA"

    if [ -z "$(ls -A "$PGDATA")" ]; then
        gosu postgres initdb
    fi

    exec gosu postgres "$@"
fi

exec "$@"


Search

    Table of Contents