docker启动nginx 末尾/bin/bash 为什么nginx无法访问

图片说明

docker run -i -t -d --name nginx1  -p 8000:80  nginx /bin/bash
docker run -i -t -d --name nginx1  -p 8000:80  nginx

开始学docker,问一下大佬们,为什么第一句启动的nginx后访问失败,第二句的就可以呢

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Python+OpenCV计算机视觉

Python+OpenCV计算机视觉

简单的Docker / Nginx错误 - PHP / Laravel

<div class="post-text" itemprop="text"> <p>I'm building a PHP and Laravel docker multi-container application by following <a href="https://medium.com/@shakyShane/laravel-docker-part-1-setup-for-development-e3daaefaf3c" rel="nofollow noreferrer">this tutorial</a>.</p> <p>It's straight forward and I followed it accurately but I'm running into the following error when running <code>docker-compose up</code>:</p> <pre><code>database_1 | 2018-07-08 16:51:11 1 [Note] mysqld: ready for connections. database_1 | Version: '5.6.40' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL) app_1 | [08-Jul-2018 15:02:52] NOTICE: fpm is running, pid 1 app_1 | [08-Jul-2018 16:51:10] NOTICE: ready to handle connections web_1 | 2018/07/08 16:52:24 [emerg] 1#1: unknown directive "listen:" in /etc/nginx/conf.d/default.conf:2 web_1 | nginx: [emerg] unknown directive "listen:" in /etc/nginx/conf.d/default.conf:2 see-number_web_1 exited with code 1 </code></pre> <p>The following is my <code>web.dockerfile</code> that handles the web/nginx service:</p> <pre><code>FROM nginx:1.10 ADD vhost.conf /etc/nginx/conf.d/default.conf </code></pre> <p>And this is the <code>vhost.conf</code> file which I'm using: </p> <pre><code>server { listen 80; index index.php index.html; root /var/www/public; location / { try_files $uri /index.php?$args; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass app:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } } </code></pre> <hr> <p>Here's the entire <code>docker-compose.yml</code> file holding it all together:</p> <pre><code>version: '2' services: # The Application app: build: context: ./ dockerfile: app.dockerfile working_dir: /var/www volumes: - ./:/var/www environment: - "DB_PORT=3306" - "DB_HOST=database" # The Web Server web: build: context: ./ dockerfile: web.dockerfile working_dir: /var/www volumes_from: - app ports: - 8080:80 # The Database database: image: mysql:5.6 volumes: - dbdata:/var/lib/mysql environment: - "MYSQL_DATABASE=homestead" - "MYSQL_USER=homestead" - "MYSQL_PASSWORD=secret" - "MYSQL_ROOT_PASSWORD=secret" ports: - "33061:3306" volumes: dbdata: </code></pre> <hr> <p>I found <a href="https://stackoverflow.com/a/21960803/6365534">this StackOverflow answer</a> that talks about hidden EOL characters but I've tried typing it out myself, and running it through <a href="https://www.textfixer.com/tools/remove-line-breaks.php" rel="nofollow noreferrer">this tool</a> in the same thread. </p> <p>Any suggestions as to why I might be getting this error?</p> <hr> <p><strong>Update 1</strong><br> As requested, I'm including the <code>docker history</code> for the web service image that's causing issues:</p> <pre><code>&lt;user&gt;:&lt;project&gt; &lt;user&gt;$ docker history see-number_web IMAGE CREATED CREATED BY SIZE COMMENT 5c0285cb9dd2 6 hours ago /bin/sh -c #(nop) ADD file:4387275b028088cf9… 453B 0346349a1a64 15 months ago /bin/sh -c #(nop) CMD ["nginx" "-g" "daemon… 0B &lt;missing&gt; 15 months ago /bin/sh -c #(nop) EXPOSE 443/tcp 80/tcp 0B &lt;missing&gt; 15 months ago /bin/sh -c ln -sf /dev/stdout /var/log/nginx… 22B &lt;missing&gt; 15 months ago /bin/sh -c apt-key adv --keyserver hkp://pgp… 58.2MB &lt;missing&gt; 15 months ago /bin/sh -c #(nop) ENV NGINX_VERSION=1.10.3-… 0B &lt;missing&gt; 15 months ago /bin/sh -c #(nop) MAINTAINER NGINX Docker M… 0B &lt;missing&gt; 15 months ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B &lt;missing&gt; 15 months ago /bin/sh -c #(nop) ADD file:4eedf861fb567fffb… 123MB </code></pre> </div>

权限被拒绝Nginx Docker

<div class="post-text" itemprop="text"> <p>I'm using docker compose to boot up a development workspace, consisting of php, nginx and mysql. Everything boots, static html get's served, but when trying to start a laravel app, i get the following error:</p> <blockquote> <p>The stream or file "/home/html/storage/logs/laravel-2019-06-10.log" could not be opened: failed to open stream: Permission denied</p> </blockquote> <p>I searched around and it looked like a permissions issue? Do note, that the docker with just the database and the build in php server does seem to work.</p> <p>My docker-compose.yml</p> <pre><code>version: "3" services: db: image: mysql command: --default-authentication-plugin=mysql_native_password restart: always environment: MYSQL_ROOT_PASSWORD: "root" ports: - 3306:3306 php-fpm: image: php:7.3-fpm-alpine links: - db volumes: - "./:/home/html/" nginx: image: nginx:1-alpine ports: - "8080:80" links: - php-fpm volumes: - "./site.conf:/etc/nginx/conf.d/default.conf" - "./:/home/html/" </code></pre> <p>My nginx config:</p> <pre><code>server { index index.php index.html; listen 80 default_server; error_log /var/log/nginx/error.log; access_log /var/log/nginx/access.log; root /home/html/public; location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass php-fpm:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } } </code></pre> <p>Kind regards :)</p> </div>

在docker文件中执行go build -o / bin / go_docker时找不到二进制文件

<div class="post-text" itemprop="text"> <p>below is the content of the dockerfile</p> <pre><code>FROM golang:1.8 as goimage ENV SRC=/go/src/ RUN mkdir -p /go/src/ RUN mkdir /go/src/go_docker WORKDIR /go/src/go_docker RUN cd /go/src/go_docker COPY StoreImage.go . RUN go build -o /bin/go_docker CMD ["/bin/go_docker"] </code></pre> <p>Docker build is successful for the above content.. But dont see the binary file generated in /bin/go_docker</p> <p>Can someone please help me with this.</p> </div>

docker获取镜像的时候报错:命令docker pull nginx

Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers) ``` ```

Nginx反向代理到Golang服务器的Docker问题

<div class="post-text" itemprop="text"> <p>I have nginx reverse proxying to a golang server, each in its own docker container and running normally. I keep getting this error in nginx when trying to connect to Go container, BOTH on my local Mac machine and on the production server Linux Debian. It was working on my local Mac machine a week ago and all of a sudden it doesn't anymore</p> <pre><code>nginx_1 | 2017/09/28 01:29:54 [error] 5#5: *12 upstream timed out (110: Connection timed out) while connecting to upstream, client: 172.23.0.1, server: , request: "GET /api/about HTTP/1.1", upstream: "http://67.199.248.12:8080/api/about", host: "localhost" </code></pre> <p>can someone explain what's going on here? What is 67.199.248.12 and why isn't Nginx able to ping/connect to the Go container?</p> <p>here's what's inside /etc/hosts in Go container</p> <pre><code>127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 172.23.0.5 31f4103f002c </code></pre> <p>here's my nginx.conf</p> <pre><code>upstream gogo { server go:8080 weight=10 max_fails=3 fail_timeout=30s; } server { listen 80; location /api/ { resolver 127.0.0.1 valid=30s; proxy_pass http://gogo; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; } } </code></pre> <p>I'm using docker-compose v3 to run nginx and docker</p> <pre><code> nginx: restart: always image: nginx volumes: - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf ports: - "80:80" command: /bin/bash -c "nginx -g 'daemon off;'" go: build: context: ./api expose: - "8080" depends_on: - nginx </code></pre> <p>go code:</p> <pre><code>func main() { router := mux.NewRouter().StrictSlash(true) router.HandleFunc("/api/about", About).Methods("GET") log.Fatal(http.ListenAndServe(":8080", router)) } </code></pre> </div>

Docker - ENTRYPOINT脚本导致重新启动

<div class="post-text" itemprop="text"> <p>I'm relatively new to Docker - I'm trying to build a system to run a Symfony 4 app, comprising of PHP-FPM, nginx and MySQL. </p> <p>Everything works as it should except one thing. When the PHP-FPM container boots, I want to run: </p> <pre><code>#!/bin/bash composer install bin/console doctrine:database:create --if-not-exists bin/console doctrine:schema:update --force bin/console doctrine:fixtures:load --no-interaction </code></pre> <p>I created a script with these commands in and then edited my DockerFile as follows: </p> <pre><code>COPY ./docker/php/startup.sh /usr/local/bin/startup.sh RUN ["chmod", "+x", "/usr/local/bin/startup.sh"] ENTRYPOINT ["/usr/local/bin/startup.sh"] </code></pre> <p>The issue I'm having is that when I run <code>docker-compose build</code> and then <code>docker-compose up</code>, I can see the script runs, but something in it causes the container to fail and restart itself - the script then runs again, and the cycle continues. The docker-compose.yml has <code>restart: unless-stopped</code> specified by the way.</p> <p>I wondered if one of the commands was exiting with a non zero code, so tried to add <code>exit 0</code> to the end of the script, but to no avail. </p> <p>Am I doing something daft? To be clear, I want this script to run automatically on the first boot of the container (it's fine if it runs every boot for what it's worth, not just <em>the very first</em> time). </p> </div>

shell 编程中docker问题

各位大神,在root用户下执行的shell脚本如何在进入docker之后执行,望指教,附上一段代码作为示例,这个代码执行不了。各位看看 #!/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games HOST_IP=`ifconfig eth0 | awk '/inet addr:/{ print $2 }' | awk -F: '{print $2 }'` cd docker-1.9.1 dpkg -i *.deb sed -i '7s/^#//' /etc/default/docker grep -q 'DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4' /etc/default/docker if [ $? -eq 0 ] then sed -i '7c DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 -g /iflytek/docker"' /etc/default/docker else echo no modify!!! fi service docker restart cd /root cat nginx-2.0.tar.gz | docker import - nginx:v2.0 docker images docker run -it --name=nginx --net=host --restart=always --privileged=true nginx:v2.0 /bin/bash -c " cd /iflytek/docker/aufs/mnt nginx=`ls -t | head -n 1` cd $nginx/usr/local/webservices/nginx/conf/ grep -q 'listen 80 backlog=65535;' $nginx/usr/local/webservices/nginx/conf//conf/nginx.conf if [ $? -eq 0 ] then echo not need modify!!! else sed -i '27c listen 80 backlog=65535;' $nginx/usr/local/webservices/nginx/conf//conf/nginx.conf fi "

Docker,清漆,连接由同行重置

<div class="post-text" itemprop="text"> <p>I'm just trying to set up a web server using Docker. I have 3 different containers:</p> <ul> <li><p>jprjr/php-fpm</p> <p><code>sudo docker run --name c_php-fpm -v $HOME/data/webstack/www:/srv/http:ro -p 9000:9000 -d jprjr/php-fpm</code></p></li> <li><p>nginx</p> <p><code>sudo docker run --name c_nginx -v $HOME/data/webstack/www:/usr/share/nginx/html:ro -p 8080:80 --link c_php-fpm:c_php-fpm -d nginx nginx</code></p></li> <li><p>jacksoncage/varnish</p> <p><code>sudo docker run --name c_varnish -i -d -p 80:80 --link c_nginx:c_nginx -e VARNISH_BACKEND_PORT=80 -e VARNISH_BACKEND_IP=c_nginx jacksoncage/varnish</code></p></li> </ul> <p>PHP and nginx are working without any problem but there is an error for varnish:</p> <p><code>curl -I http://localhost/index.html curl: (56) Recv failure: Connection reset by peer</code></p> <p><code>sudo docker ps</code> return:</p> <p><code>CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4ee21c4a80e2 jacksoncage/varnish:latest "/bin/bash" 25 minutes ago Up 25 minutes 0.0.0.0:80-&gt;80/tcp c_varnish<br> 4dcc7babd92c nginx:latest "nginx" 16 hours ago Up 48 minutes 443/tcp, 0.0.0.0:8080-&gt;80/tcp c_nginx<br> 3c0f8c1d634c jprjr/php-fpm:latest "php-fpm -F" 16 hours ago Up 48 minutes 0.0.0.0:9000-&gt;9000/tcp c_php-fpm</code></p> <p><code>sudo docker logs c_varnish</code> return nothing.</p> <p>Thanks !</p> </div>

docker-compose up没有建立

<div class="post-text" itemprop="text"> <p>I am trying to build and run a golang app with docker-compose. Here are my settings:</p> <pre><code>./docker/Dockerfile ./main.go Makefile </code></pre> <p>Makefile</p> <pre><code>compose: env GOOS=linux GOARCH=amd64 GOARM=7 go build cd docker &amp;&amp; docker-compose up </code></pre> <p>./docker/Dockerfile</p> <pre><code>FROM golang:1.11 COPY app . CMD ["./app"] </code></pre> <p>./docker/docker-compose.yml</p> <pre><code>version: '3' services: app: build: context: ../ dockerfile: ./docker/Dockerfile env_file: ./app.env ports: - '9292:8000' </code></pre> <p>I run the following command, expecting to build a new binary and run it inside a Docker container.</p> <pre><code>$make compose </code></pre> <p>It runs great, but if I run the same command after updating <code>main.go</code> the new binary isn't copied to docker container. The docker container seems to use the previous binary (i.e. the first binary that was copied when the container was first constructed).</p> <p>Can someone explain why this is happening and what should I do to fix it?</p> </div>

我可以在主机上使用NginX,在docker容器中使用多个版本的PHP

<div class="post-text" itemprop="text"> <p>I found a similar question <a href="https://stackoverflow.com/questions/43644963/multiple-versions-of-php-through-nginx-in-docker">here</a> but it didn't quite answer my question.</p> <p>I've always installed my stack locally for development, NginX, PHP7, MySQL, and Couchbase. No Problems.</p> <p>Now I have to work on a project that requires a lower version of PHP... And my team will have to work on it as well, so I've looked to Docker to try to find the solution.</p> <p>In my existing NGINX conf files I send the requests off to php-fpm like this</p> <pre><code> location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_ignore_client_abort on; fastcgi_param SERVER_NAME $http_host; } </code></pre> <p>See the line</p> <pre><code>fastcgi_pass 127.0.0.1:9000; </code></pre> <p>?</p> <p>I was hoping to be able to create a docker container running a specific version of PHP and write it into the server block as above but with</p> <pre><code>fastcgi_pass 172.17.0.1:9000; </code></pre> <p>Where 172.17.0.1 is the IP of the container.</p> <p>I have used, very simply,</p> <pre><code>FROM php:7.1-fpm EXPOSE 9000 </code></pre> <p>As my dockerfile. I can build an image, run the container, run bash in the container and see that PHP -I and PHP -v return what I expect.</p> <p>Running docker inspect has given me two IP addresses, 172.17.0.1, and 172.17.0.2 (I've tried both in the example above)</p> <p>However, this set up is not working - when I try to visit the site in a browser I get an NGINX 504 gateway timeout error.</p> <p>Guessing I'm missing something, but not sure what.</p> <p>Happy to use docker compose if I need to, happy to mount volumes into the container if I need to. Just not sure what I need!:)</p> </div>

多个项目之间的Docker连接被拒绝

<div class="post-text" itemprop="text"> <p>I set up 2 projects (Admin and API) and try to move into docker on local.</p> <p>I can access the running web instances on both without any problems, but when the Admin tries to make a Curl requests to the API, I get a cURL error:</p> <blockquote> <p>cURL error 7: Failed to connect to localhost port 8080</p> </blockquote> <p>This is my docker-compose.yml file contents:</p> <pre><code>version: "3.1" services: memcached: image: memcached:alpine container_name: project-admin-memcached redis: image: redis:alpine container_name: project-admin-redis mariadb: image: mariadb:10.1 container_name: project-admin-mariadb working_dir: /application volumes: - ./Projects:/application environment: - MYSQL_ROOT_PASSWORD=docker - MYSQL_DATABASE=db_test - MYSQL_USER=test - MYSQL_PASSWORD=test ports: - "8083:3306" # docker-compose exec webserver sh # docker exec -it project-admin-webserver nginx -s reload webserver: image: nginx:alpine container_name: project-admin-webserver working_dir: /application volumes: - ./Projects/Api:/application/api - ./Projects/Admin:/application/admin - ./Docker/nginx:/etc/nginx/conf.d ports: - "8080:8080" - "8090:8090" # docker-compose exec php-fpm bash php-fpm: build: Docker/php-fpm container_name: project-admin-php-fpm working_dir: /application volumes: - ./Projects:/application - ./Docker/php-fpm/php-ini-overrides.ini:/etc/php/7.2/fpm/conf.d/99-overrides.ini </code></pre> <p>I can access both projects from my browser with:</p> <p><a href="http://localhost:8080/" rel="nofollow noreferrer">http://localhost:8080/</a> &lt;= API</p> <p><a href="http://localhost:8090/" rel="nofollow noreferrer">http://localhost:8090/</a> &lt;= Admin</p> <p>How can I fix this?</p> </div>

如何正确配置docker中的supervisor

<div class="post-text" itemprop="text"> <p>I have a working laravel environment using docker. my projects has multiple services in different container such as redis, mongodb, mysqldb and nodejs. I want to use supervisor on my project to interact with redis for the queues and php to run the job. I have done some testing and research but I really can't make it work. </p> <p>so here is my DockerFile:</p> <pre><code>FROM php:7.3-fpm # Copy composer.lock and composer.json COPY composer.lock composer.json /var/www/ # Set working directory WORKDIR /var/www # Install dependencies RUN apt-get update &amp;&amp; apt-get install -y \ build-essential \ mariadb-client \ libpng-dev \ libzip-dev \ libjpeg62-turbo-dev \ libfreetype6-dev \ locales \ zip \ jpegoptim optipng pngquant gifsicle \ vim \ unzip \ git \ curl \ cron \ supervisor # Clear cache RUN apt-get clean &amp;&amp; rm -rf /var/lib/apt/lists/* # Install extensions RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl RUN docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/ RUN docker-php-ext-install gd RUN docker-php-ext-configure bcmath --enable-bcmath RUN docker-php-ext-install bcmath # install mongodb ext RUN pecl install mongodb \ &amp;&amp; docker-php-ext-enable mongodb # Install composer RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer # Add user for laravel application RUN groupadd -g 1000 www RUN useradd -u 1000 -ms /bin/bash -g www www # Copy supervisor configs COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf # Copy existing application directory contents COPY . /var/www # Copy existing application directory permissions COPY --chown=www:www . /var/www COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf CMD ["/usr/bin/supervisord"] # Change current user to www USER www # Expose port 9000 and start php-fpm server EXPOSE 9000 CMD ["php-fpm"] </code></pre> <p>and my docker-compose.yml file</p> <pre><code>version: '3' services: #PHP Service php: build: context: . dockerfile: Dockerfile image: digitalocean.com/php container_name: php restart: unless-stopped tty: true environment: SERVICE_NAME: php SERVICE_TAGS: dev working_dir: /var/www volumes: - ./:/var/www - ./php/local.ini:/usr/local/etc/php/conf.d/local.ini - ./supervisord.conf:/etc/supervisor/conf.d/supervisord.conf networks: - app-network #NODEJS Service nodejs: image: node:10 container_name: nodejs restart: unless-stopped working_dir: /var/www volumes: - ./:/var/www tty: true networks: - app-network #Nginx Service nginx: image: nginx:alpine container_name: nginx restart: unless-stopped tty: true ports: - "80:80" - "443:443" volumes: - ./:/var/www - ./nginx/conf.d/:/etc/nginx/conf.d/ networks: - app-network #MySQL Service mysqldb: image: mysql:5.7.22 container_name: mysqldb restart: unless-stopped tty: true ports: - "3306:3306" environment: MYSQL_DATABASE: ${DB_DATABASE} MYSQL_USER: ${DB_USERNAME} MYSQL_PASSWORD: ${DB_PASSWORD} MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD} SERVICE_TAGS: dev SERVICE_NAME: mysql volumes: - dbdata:/var/lib/mysql - ./mysql/my.cnf:/etc/mysql/my.cnf networks: - app-network #MongoDB Service mongodb: image: mongo:3 container_name: mongodb restart: unless-stopped tty: true ports: - "27017:27017" networks: - app-network #Redis Service redis: image: redis container_name: redis restart: unless-stopped tty: true ports: - "${REDIS_PORT}:6379" networks: - app-network #Docker Networks networks: app-network: driver: bridge #Volumes volumes: dbdata: driver: local </code></pre> <p>you might also want to see my supervisord.conf</p> <pre><code>[supervisord] user=www nodaemon=true logfile=/dev/null logfile_maxbytes=0 pidfile=/var/run/supervisord.pid loglevel = INFO [unix_http_server] file=/var/run/supervisor.sock chmod=0700 username=www password=www [supervisorctl] serverurl=unix:///var/run/supervisord.sock username=www password=www [rpcinterface:supervisor] supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface [program:php-fpm] command = /usr/local/sbin/php-fpm autostart=true autorestart=true priority=5 stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 [program:ohwo-worker] process_name=%(program_name)s_%(process_num)02d command=php /var/www/artisan horizon autostart=false autorestart=true user=www numprocs=1 redirect_stderr=true stdout_logfile=/var/www/laravel-worker.log </code></pre> <p>so from that setup. when the containers is UP it seems that supervisord is not working because if I run <code>php artisan horizon</code> manually on my php container the queuing works perfectly. btw horizon is the tool i use for queuing. </p> <p>and then I also try to run <code>supervisorctl</code> on my php container and I got this error <code>unix:///var/run/supervisord.sock no such file</code></p> <p>so I'm just pretty new to docker just started few months ago. I do know how to configure supervisord on linux but i can't make it work on docker. </p> <p>so please pardon my stupidity :) </p> </div>

求助:Nginx+Gunicorn部署 Django后遇到Not Found错误

问题描述: Nginx+Gunicorn部署 Django后遇到Not Found错误 ![图片说明](https://img-ask.csdn.net/upload/202003/09/1583754685_161046.png) 服务器版本:CentOS 7.5 x64 说明:在虚拟环境中使用django自带的runserver运行(0.0.0.0:8000)后,使用公网IP:端口/index可以正常访问项目,关闭debug后使用 ``` pipenv run gunicorn blogproject.wsgi -w 2 -k gthread -b 0.0.0.0:8000 ``` 运行也可以正常访问,但是开启nginx后运行就出现如图错误。 /etc/nginx/conf.d/django-blog.conf配置如下 ``` [zijeak@VM_16_8_centos conf.d]$ cat django-blog.conf server { charset utf-8; listen 80; server_name 119.27.169.70; location /static { alias /home/zijeak/apps/django-blog/static; } location / { proxy_set_header Host $host; proxy_pass http://127.0.0.1:8000; } } ``` 查看nginx日志如下: ``` [zijeak@VM_16_8_centos conf.d]$ sudo nginx -t [sudo] password for zijeak: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful ``` 项目目录如下: ![图片说明](https://img-ask.csdn.net/upload/202003/09/1583755294_598395.png)

nginx报错,域名下子目录访问报错404

nginx 报错: 访问域名:http://webapp.otcwallet.io/otc/ 域名下子目录所有文件跳转到主目录然后报错404,我想要的效果是域名下可以建多个工程子目录,通过加目录就可以访问。 ![图片说明](https://img-ask.csdn.net/upload/201912/23/1577085321_597173.png) ``` location /otc { root /www/wwwroot/webapp; index index.html index.htm; #proxy_pass http://ant_web/; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Port $server_port; if ($request_method = POST ) { proxy_pass http://bc; } try_files $uri $uri/ /index.html?$query_string; } ``` 代理设置

无法连接到postgres(用户密码验证失败-docker)

<div class="post-text" itemprop="text"> <p>I was trying to run docker compose to set up nginx, golang server and postgresql. The problem is that I can't connect to the database:</p> <p><a href="https://i.stack.imgur.com/ZB7bP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZB7bP.jpg" alt="enter image description here"></a></p> <p>Initially, I was trying to connect to postgres with this instruction:</p> <pre><code>db, err = gorm.Open("postgres", "host=db port=5432 user=sigbrian password=example sslmode=disable") </code></pre> <p>With this docker-compose file:</p> <pre><code>version: '3.2' # volumes: # database_data: # driver: local services: db: image: postgres restart: always environment: - POSTGRES_DB:sigdb - POSTGRES_USER:sigbrian - POSTGRES_PASSWORD:example ports: - '5432:5432' # volumes: # - database_data:/var/lib/postgresql/data golang-app: build: context: . dockerfile: Dockerfile # command: ["./wait-for-it.sh", "db:5432"] # ports: # - '80:8888' expose: - '8080' depends_on: - "db" links: - "db" nginx-proxy-and-webserver: image: nginx:1.15.5-alpine ports: - '80:80' volumes: - ./nginx.conf:/etc/nginx/nginx.conf - ./static:/var/www/sig/static depends_on: - "golang-app" links: - "golang-app" </code></pre> <p>But when I comment the postgres user, database and password environment variables from the file, and try to make the connection this way: </p> <pre><code>db, err = gorm.Open("postgres", "host=db port=5432 user=postgres sslmode=disable") </code></pre> <p>Still throws the same error. I appreciate any help.</p> </div>

Supervisord | 不支持的系统调用

<div class="post-text" itemprop="text"> <p>I try to use supervisord in order to link PHP &amp; Nginx, my container runs locally but once pushed to Cloud Run, I go a 502 error which informs me that the PHP socket can't be found.</p> <p>I have a non-Alpine image which runs with the same configuration and everything goes right, I've tried to use the PHP default port (9000) and everything works but I've seen that using Unix socket can be a better idea. </p> <p>Here's the Dockerfile used: </p> <pre><code>FROM php:7.3.5-alpine3.9 as base ARG REVISION LABEL org.opencontainers.image.authors=contact@guillaumeloulier.fr LABEL org.opencontainers.image.source=https://gitlab.com/Guikingone/Portfolio LABEL org.opencontainers.image.revision=$REVISION ENV APP_DIR=/srv/app \ APP_ENV=prod \ APP_FRONT_CONTROLLER=index.php \ APP_LOCALE=fr \ APP_USER=portfolio-user \ APP_USER_GROUP=portfolio \ APP_PORT=8080 \ COMPOSER_DIR=/opt/composer \ COMPOSER_ALLOW_SUPERUSER=1 \ NGINX_DIR=/etc/nginx \ NGINX_VERSION=1.14.2-r1 \ PHP_FPM_CONF_DIR=/usr/local/etc/php-fpm.d/ \ SUPERVISORD_CONF_DIR=/etc/supervisor \ SUPERVISOR_VERSION=3.3.4-r1 \ BUILD_SCRIPTS_DIR=/build-scripts # Supervisord conf to be copied at the end. COPY docker/prod/php/scripts/*.sh $BUILD_SCRIPTS_DIR/ # Core dependencies installation (installed as a virtual package in order to remove it later) RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \ &amp;&amp; apk add --no-cache --virtual .bash bash=4.4.19-r1 \ &amp;&amp; apk add --no-cache --virtual .core-php-deps icu-dev=62.1-r0 \ &amp;&amp; rm -rf /var/cache/apk/* \ &amp;&amp; docker-php-ext-install \ intl \ opcache \ &amp;&amp; docker-php-ext-configure intl \ &amp;&amp; docker-php-ext-enable opcache \ &amp;&amp; apk del .build-deps .phpize-deps-configure # User creation RUN apk add --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted --virtual .user-deps gosu=1.10-r0 \ &amp;&amp; rm -rf /var/cache/apk/* \ &amp;&amp; addgroup $APP_USER_GROUP \ &amp;&amp; adduser -D -h /home/portfolio -s /bin/bash -G $APP_USER_GROUP $APP_USER \ &amp;&amp; chown -R $APP_USER $BUILD_SCRIPTS_DIR \ &amp;&amp; apk del .user-deps # Nginx &amp; Supervisor installation RUN apk add --no-cache --virtual .http-deps nginx=$NGINX_VERSION supervisor=$SUPERVISOR_VERSION \ &amp;&amp; rm -rf /var/cache/apk/* \ &amp;&amp; ln -sf /dev/stdout /var/log/nginx/access.log \ &amp;&amp; ln -sf /dev/stderr /var/log/nginx/error.log RUN mkdir -p $APP_DIR $BUILD_SCRIPTS_DIR \ &amp;&amp; chown -R $APP_USER $APP_DIR \ &amp;&amp; chmod -R 755 $APP_DIR COPY docker/prod/php/conf/php.ini $PHP_INI_DIR/php.ini COPY docker/prod/php/conf/fpm.conf $PHP_FPM_CONF_DIR/fpm.conf COPY docker/prod/nginx/conf/nginx.conf $NGINX_DIR/nginx.conf COPY docker/prod/supervisord/supervisord.conf $SUPERVISORD_CONF_DIR/supervisord.conf # Used to check that PHP-FPM works HEALTHCHECK --interval=5s --timeout=3s \ CMD curl -f http://localhost/ping || exit 1 EXPOSE $APP_PORT 443 CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf"] # Production build FROM base as production COPY docker/prod/nginx/conf/portfolio.conf $NGINX_DIR/conf.d/portfolio.conf WORKDIR $APP_DIR COPY . . # The vendors are installed after the whole project is copied, this way, we can dump the autoload properly. # The unrequired directories are also removed. RUN /bin/bash "$BUILD_SCRIPTS_DIR/install_composer.sh" \ &amp;&amp; /bin/bash "$BUILD_SCRIPTS_DIR/composer_dependencies.sh" \ &amp;&amp; rm -rf $BUILD_SCRIPTS_DIR \ /usr/bin/git* \ /lib/apk/db/installed \ /usr/local/bin/composer \ node_modules/ </code></pre> <p>And here's the supervisor configuration file:</p> <pre><code>[supervisord] nodaemon = true logfile = /dev/null logfile_maxbytes = 0 pidfile = /var/run/supervisord.pid loglevel = INFO [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [program:php-fpm] command = /usr/local/sbin/php-fpm autostart = true autorestart = true priority = 5 stdout_logfile = /dev/stdout stdout_logfile_maxbytes = 0 stderr_logfile = /dev/stderr stderr_logfile_maxbytes = 0 [program:nginx] command = /usr/sbin/nginx -g "daemon off;" autostart = true autorestart = true priority = 10 stdout_events_enabled = true stderr_events_enabled = true stdout_logfile = /dev/stdout stdout_logfile_maxbytes = 0 stderr_logfile = /dev/stderr stderr_logfile_maxbytes = 0 [include] files = /etc/supervisor/**/*.conf </code></pre> <p>Here's the error log in StackDriver logging linked to the container sandox:</p> <pre><code>2019-05-19 11:31:50.246 CEST Container Sandbox Limitation: Unsupported syscall prctl(0x4,0x1,0x0,0x0,0x0,0x20) </code></pre> <p>Thanks for the help.</p> </div>

启动容器进程导致“ exec:\” / app \“:权限被拒绝”:未知

<div class="post-text" itemprop="text"> <p>When I was trying to build golang using docker</p> <p>The image build of docker was successful, but the following error occurred when running with docker run</p> <pre><code>docker: Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "exec: \"/app\": permission denied": unknown. </code></pre> <p>I think this error cause no user add, so I added group and user as below</p> <pre><code>RUN groupadd -g 10001 myapp \ &amp;&amp; useradd -u 10001 -g myapp myapp </code></pre> <p>but didn't fix.</p> <p>Here is my source docker file</p> <pre><code>FROM golang:1.12.9 as builder ADD . /go/src/appname/ WORKDIR /go/src/appname/ ENV GO111MODULE=on COPY go.mod . COPY go.sum . RUN go mod download COPY . . RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make build target=prod FROM alpine RUN apk update \ &amp;&amp; apk add --no-cache COPY --from=builder /go/src/ /app ENTRYPOINT [ "/app" ] </code></pre> <p>thanks</p> </div>

通过docker中的supervisor执行PHP脚本

<div class="post-text" itemprop="text"> <p>I want to execute a PHP script in my docker container on a regularly basis, let's say every 5 minutes - with supervisord controlling.</p> <p><strong>My Dockerfile:</strong></p> <pre><code>FROM php:5.6-apache RUN apt-get update &amp;&amp; apt-get install -y \ cron \ rsyslog \ supervisor COPY supervisord/*.conf /etc/supervisor/conf.d/ COPY crontab /etc/cron.d/cron RUN rm -Rf /etc/cron.daily &amp;&amp; \ rm -Rf /etc/cron.weekly &amp;&amp; \ rm -Rf /etc/cron.monthly &amp;&amp; \ rm -Rf /etc/cron.hourly &amp;&amp; \ chmod a+x /etc/cron.d/cron EXPOSE 80 CMD exec supervisord -n </code></pre> <p><strong>My crontab file:</strong></p> <pre><code>PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin */5 * * * * root cd /var/www/html/market/autoFetch &amp;&amp; /usr/local/bin/php fetchStock.php &gt;/dev/null 2&gt;&amp;1 </code></pre> <p><strong>What happens, when I start my server:</strong></p> <pre><code>php_1 | /usr/lib/python2.7/dist-packages/supervisor/options.py:298: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security. php_1 | 'Supervisord is running as root and it is searching ' php_1 | 2018-08-26 08:45:52,515 CRIT Supervisor running as root (no user in config file) php_1 | 2018-08-26 08:45:52,516 INFO Included extra file "/etc/supervisor/conf.d/supervisord.conf" during parsing php_1 | 2018-08-26 08:45:52,522 INFO RPC interface 'supervisor' initialized php_1 | 2018-08-26 08:45:52,523 CRIT Server 'unix_http_server' running without any HTTP authentication checking php_1 | 2018-08-26 08:45:52,523 INFO supervisord started with pid 1 php_1 | 2018-08-26 08:45:53,526 INFO spawned: 'cron' with pid 8 php_1 | 2018-08-26 08:45:53,528 INFO spawned: 'rsyslogd' with pid 9 php_1 | 2018-08-26 08:45:53,531 INFO spawned: 'apache2' with pid 10 php_1 | 2018-08-26 08:45:54,607 INFO success: cron entered RUNNING state, process has stayed up for &gt; than 1 seconds (startsecs) php_1 | 2018-08-26 08:45:54,607 INFO success: rsyslogd entered RUNNING state, process has stayed up for &gt; than 1 seconds (startsecs) php_1 | 2018-08-26 08:45:54,607 INFO success: apache2 entered RUNNING state, process has stayed up for &gt; than 1 seconds (startsecs) php_1 | 2018-08-26 09:00:11,493 INFO reaped unknown pid 21 ... </code></pre> <p>The server is running &amp; it looks like the cronjob is working as expected, but the output that I expect after the php script got executed (creation of a file) does not happen. </p> <p><strong>I for sure cross checked my command:</strong> </p> <pre><code>cd /var/www/html/market/autoFetch &amp;&amp; /usr/local/bin/php fetchStock.php &gt;/dev/null 2&gt;&amp;1 </code></pre> <p>It will result in the creation of the file I expect the script to create (it takes some time because lots of data is fetched) and it will output whatever was echoed inside the PHP into my terminal.</p> <p>Do you have an idea what could go wrong?</p> </div>

基于ARM运行Linux操作系统,终端运行文件报错:cannot execute binary file

1、硬件系统:Zynq开发板,ARM架构运行arm-linaro-ubuntu操作系统(32-bit) 2、软件:自己利用Python和PyQt写的一个简单的软件,最后利用Pyinstaller进行打包,在我做开发的电脑(也是32-bit,也是ubuntu系统)上成功打包运行 3、问题:打包后由开发电脑向Zynq开发板移植后,在终端运行打包后的文件,报错:cannot execute binary file 请问问题出在哪里呢?

2019 Python开发者日-培训

2019 Python开发者日-培训

150讲轻松搞定Python网络爬虫

150讲轻松搞定Python网络爬虫

设计模式(JAVA语言实现)--20种设计模式附带源码

设计模式(JAVA语言实现)--20种设计模式附带源码

YOLOv3目标检测实战:训练自己的数据集

YOLOv3目标检测实战:训练自己的数据集

java后台+微信小程序 实现完整的点餐系统

java后台+微信小程序 实现完整的点餐系统

三个项目玩转深度学习(附1G源码)

三个项目玩转深度学习(附1G源码)

初级玩转Linux+Ubuntu(嵌入式开发基础课程)

初级玩转Linux+Ubuntu(嵌入式开发基础课程)

2019 AI开发者大会

2019 AI开发者大会

玩转Linux:常用命令实例指南

玩转Linux:常用命令实例指南

一学即懂的计算机视觉(第一季)

一学即懂的计算机视觉(第一季)

4小时玩转微信小程序——基础入门与微信支付实战

4小时玩转微信小程序——基础入门与微信支付实战

Git 实用技巧

Git 实用技巧

Python数据清洗实战入门

Python数据清洗实战入门

使用TensorFlow+keras快速构建图像分类模型

使用TensorFlow+keras快速构建图像分类模型

实用主义学Python(小白也容易上手的Python实用案例)

实用主义学Python(小白也容易上手的Python实用案例)

程序员的算法通关课:知己知彼(第一季)

程序员的算法通关课:知己知彼(第一季)

MySQL数据库从入门到实战应用

MySQL数据库从入门到实战应用

机器学习初学者必会的案例精讲

机器学习初学者必会的案例精讲

手把手实现Java图书管理系统(附源码)

手把手实现Java图书管理系统(附源码)

极简JAVA学习营第四期(报名以后加助教微信:eduxy-1)

极简JAVA学习营第四期(报名以后加助教微信:eduxy-1)

.net core快速开发框架

.net core快速开发框架

玩转Python-Python3基础入门

玩转Python-Python3基础入门

Python数据挖掘简易入门

Python数据挖掘简易入门

微信公众平台开发入门

微信公众平台开发入门

程序员的兼职技能课

程序员的兼职技能课

Windows版YOLOv4目标检测实战:训练自己的数据集

Windows版YOLOv4目标检测实战:训练自己的数据集

HoloLens2开发入门教程

HoloLens2开发入门教程

微信小程序开发实战

微信小程序开发实战

Java8零基础入门视频教程

Java8零基础入门视频教程

相关热词 c# 局部 截图 页面 c#实现简单的文件管理器 c# where c# 取文件夹路径 c# 对比 当天 c# fir 滤波器 c# 和站 队列 c# txt 去空格 c#移除其他类事件 c# 自动截屏
立即提问