How to build drone image for ARMv7? - docker

First, I downloaded the drone image:
go get github.com/drone/drone/cmd/...
Second, I built the image for arm:
GOARM=7 go build -o release/drone-server github.com/drone/drone/cmd/drone-server
After that, I built the image for docker:
docker -f ./go-workspace/src/github.com/drone/drone/Dockerfile build -t drone/drone .
The docker file looks like so:
# docker build --rm -t drone/drone .
FROM drone/ca-certs
EXPOSE 8000 9000 80 443
ENV DATABASE_DRIVER=sqlite3
ENV DATABASE_CONFIG=/var/lib/drone/drone.sqlite
ENV GODEBUG=netdns=go
ENV XDG_CACHE_HOME /var/lib/drone
ADD release/drone-server /bin/
ENTRYPOINT ["/bin/drone-server"]
That's my docker-compose.yml:
version: '2'
services:
drone-server:
image: drone/drone:latest
ports:
- 8000:8000
- 9000:9000
volumes:
- /var/lib/drone:/var/lib/drone
restart: always
env_file:
- /etc/drone/server.env
drone-agent:
image: drone/agent:linux-arm
command: agent
depends_on:
- drone-server
volumes:
- /var/run/docker.sock:/var/run/docker.sock
restart: always
env_file:
- /etc/drone/agent.env
The agent.env file:
DRONE_SECRET=xxx
DRONE_SERVER=[server-hostname]:9000
DOCKER_ARCH=arm
The server.env file:
# Service settings
DRONE_SECRET=xxx
DRONE_HOST=https://[server-hostname]/drone
DRONE_OPEN=false
DRONE_GOGS=true
DRONE_GOGS_URL=https://[server-hostname]/git
DRONE_GOGS_PRIVATE_MODE=true
However, when running docker-compose -f /etc/drone/docker-compose.yml up, I get the following error:
drone-server_1 | standard_init_linux.go:190: exec user process caused "no such file or directory"
And the drone-server exits with code 1.
I configured Apache to reach drone trough a proxy as described here: http://readme.drone.io/0.5/install/setup/apache/
Any help is appreciated.

Related

'(root) additional property nginx is not allowed' while installing an app in Salesforce using Docker

I'm following this tutorial https://trailhead.salesforce.com/en/content/learn/modules/user-interface-api/install-sample-app?trail_id=force_com_dev_intermediate and I have never used docker before.
Steps I followed:
Cloned the repo
Installed docker for windows and it is perfectly installed.
Tried to run this cmd on the repo docker-compose build && docker-compose up -d
While running this cmd, I'm getting the same error.
E:\Salesforce\RecordViewer>docker-compose build && docker-compose up -d
(root) Additional property nginx is not allowed
I found this answer: https://stackoverflow.com/a/38717336/279771
Basically I needed to add services: to the docker-compose.yml so it looks like this:
services:
web:
build: .
command: 'bash -c ''node app.js'''
working_dir: /usr/src/app
environment:
PORT: 8050
NGINX_PORT: 8443
volumes:
- './views:/app/user/views:ro'
nginx:
build: nginx
ports:
- '8080:80'
- '8443:443'
links:
- web:web
volumes_from:
- web

Executable not found in docker compose /bin/sh: 1: main: not found

I am trying to run my restful api in docker but having issue with my golang executable it is always not found. Here is my Dockerfile
# Start from golang base image
FROM golang:1.15.2
#Set ENV
ENV DB_HOST=fullstack-mysql \
DB_DRIVER=mysql \
DB_USER=root \
DB_PASSWORD=root \
DB_NAME=link_aja \
DB_PORT=3306 \
APP_NAME=golang-linkaja \
CGO_ENABLED=0
# Copy the source from the current directory to the working Directory inside the container
COPY . /usr/src/${APP_NAME}
# Move to working directory
WORKDIR /usr/src/${APP_NAME}
#install depedencies
RUN go mod download
# Build the application
RUN go build -o ${APP_NAME}
# Expose port 3000 to the outside world
EXPOSE 3000
#Command to run the executable
CMD ${APP_NAME}
And here is my docker-compose.yml
version: '3'
services:
app:
container_name: golang-linkaja
build: .
ports:
- 3000:3000
restart: on-failure
volumes:
- api:/usr/src/${APP_NAME}
depends_on:
- fullstack-mysql
networks:
- fullstack
fullstack-mysql:
image: mysql:5.7
container_name: full_db_mysql
ports:
- 3306:3306
environment:
- MYSQL_ROOT_HOST=${DB_HOST}
- MYSQL_USER=${DB_USER}
- MYSQL_PASSWORD=${DB_PASSWORD}
- MYSQL_DATABASE=${DB_NAME}
- MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
volumes:
- database_mysql:/var/lib/mysql
networks:
- fullstack
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin_container
depends_on:
- fullstack-mysql
environment:
- PMA_HOST=fullstack-mysql #DB_HOST env must be the same with this
- PMA_USER=${DB_USER}
- PMA_PORT=${DB_PORT}
- PMA_PASSWORD=${DB_PASSWORD}
ports:
- 9090:80
restart: always
networks:
- fullstack
volumes:
api:
database_mysql:
# Networks to be created to facilitate communication between containers
networks:
fullstack:
driver: bridge
Everything works correctly except for the Go app itself, here is the error that I get
golang-linkaja | /bin/sh: 1: golang-linkaja: not found
Could i get any help please? i'm new and still learning docker
Thanks in advance!
Update: here are the other things i've tried:
1.Changing CMD to CMD ["./usr/src/${APP_NAME}/${APP_NAME}"]
Return error golang-linkaja | sh: 1: /usr/src/golang-linkaja/golang-linkaja: not found
2.Changing to CMD [ "./golang-linkaja" ] and CMD [ "./${APP_NAME}" ]
Return error ERROR: for golang-linkaja Cannot start service app: OCI runtime create failed: container_linux.go:370: starting container process caused: exec: "./golang-linkaja": stat ./golang-linkaja: no such file or directory: unknown
You need to remove the volume - api:/usr/src/${APP_NAME} from your compose. You have already copied what you need in your Dockerfile. The volume(defined in compose) is overwriting all your data and hence your built binary is not found.
Just remove the volume and try to rebuild and start the container again .... and change your cmd to CMD [ "./${APP_NAME}" ]
In your Dockerfile, you try to run your executables without using ./ prefix, So OS search executable on system folders and can not find it. Add ./ beginning of your CMD or use the absolute path of the executable.
#Command to run the executable
CMD ./${APP_NAME}
or
#Command to run the executable
CMD /usr/src/${APP_NAME}

docker-compose unable to connect to container in build process

I try i setup a Shopware Docker Container for development. I setup a Dockerfile for the Shopware initialize process but every time i run the build process shopware return this error message:
mysql -u 'root' -p'root' -h 'dbs' --port='3306' -e "DROP DATABASE IF EXISTS `shopware6dev`"
ERROR 2005 (HY000): Unknown MySQL server host 'dbs' (-2)
i think docker setup the default network after all build processes are done but i need to connect before all containers are ready. The depends_on option brings nothing. I hope anyone have a idea to solve this problem.
This is my docker-compose file:
version: '3'
services:
shopwaredev:
build:
context: ./docker/web
dockerfile: Dockerfile
volumes:
- ./log:/var/log/apache2
environment:
- VIRTUAL_HOST=shopware6dev.test,www.shopware6dev.test
- HTTPS_METHOD=noredirect
restart: on-failure:10
depends_on:
- dbs
adminer:
image: adminer
restart: on-failure:10
ports:
- 8080:8080
dbs:
image: "mysql:5.7"
volumes:
- ./mysql57:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=shopware6dev
restart: on-failure:10
nginx-proxy:
image: solution360/nginx-proxy
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./ssl:/etc/nginx/certs
restart: on-failure:10
and this is my dockerfile for web shopwaredev container:
FROM solution360/apache24-php74-shopware6
WORKDIR /var/www/html
RUN rm index.html
RUN git clone https://github.com/shopware/development.git .
RUN cp .psh.yaml.dist .psh.yaml
RUN sed -i 's|DB_USER: "app"|DB_USER: "root"|g' .psh.yaml
RUN sed -i 's|DB_PASSWORD: "app"|DB_PASSWORD: "root"|g' .psh.yaml
RUN sed -i 's|DB_HOST: "mysql"|DB_HOST: "dbs"|g' .psh.yaml
RUN sed -i 's|DB_NAME: "shopware"|DB_NAME: "shopware6dev"|g' .psh.yaml
RUN sed -i 's|APP_URL: "http://localhost:8000"|APP_URL: "http://shopware6dev.test"|g' .psh.yaml
RUN ./psh.phar install

Set secomp to unconfined in docker-compose

I need to be able fork a process. As i understand it i need to set the security-opt. I have tried doing this with docker command and it works fine. However when i do this in a docker-compose file it seem to do nothing, maybe I'm not using compose right.
Docker
docker run --security-opt=seccomp:unconfined <id> dlv debug --listen=:2345 --headless --log ./cmd/main.go
Docker-compose
Setup
docker-compose.yml
networks:
backend:
services:
example:
build: .
security_opt:
- seccomp:unconfined
networks:
- backend
ports:
- "5002:5002"
Dockerfile
FROM golang:1.8
RUN go get -u github.com/derekparker/delve/cmd/dlv
RUN dlv debug --listen=:2345 --headless --log ./cmd/main.go
command
docker-compose -f docker-compose.yml up --build --abort-on-container-exit
Result
2017/09/04 15:58:33 server.go:73: Using API v1 2017/09/04 15:58:33
debugger.go:97: launching process with args: [/go/src/debug] could not
launch process: fork/exec /go/src/debug: operation not permitted
The compose syntax is correct. But the security_opt will be applied to the new instance of the container and thus is not available at build time like you are trying to do with the Dockerfile RUN command.
The correct way should be :
Dockerfile:
FROM golang:1.8
RUN go get -u github.com/derekparker/delve/cmd/dlv
docker-compose.yml
networks:
backend:
services:
example:
build: .
security_opt:
- seccomp:unconfined
networks:
- backend
ports:
- "5002:5002"
entrypoint: ['/usr/local/bin/dlv', '--listen=: 2345', '--headless=true', '--api-version=2', 'exec', 'cmd/main.go']

Links in docker-compose are not resolved

docker-compose.yml
version: '2'
services:
redis:
image: redis
ports:
- "6379"
myapp:
build: ./myapp
ports:
- "80:80"
links:
- redis
depends_on:
- redis
Dockerfile of myapp
FROM <BASE_IMAGE>
EXPOSE 80
CMD ["curl", "http://redis"]
When I run docker-compose up -d --build and then docker run prefix_myapp_1, I'm getting the 'Host is not resolved' error after 4-5 seconds.
If I change the Dockerfile, say, as follows:
FROM <BASE_IMAGE>
EXPOSE 80
CMD sleep 1000000000
then do docker exec -it prefix_myapp_1 bash, and try running curl http://redis, the host is resolved successfully.
Where the problem lies?

Resources