Let's say you are running your server using:
docker-compose up
You may be trying to run bash for your container,
docker ps (grab the container id)
docker exec -it 301 bash
When you cd into a mounted host volume, if you get a "killed" message or it just logs you out, try the following:
boot2docker restart
Showing posts with label boot2docker. Show all posts
Showing posts with label boot2docker. Show all posts
Sunday, July 5, 2015
docker - error fetching ubuntu packages
If you ever see the following error and you are using boot2docker, run "boot2docker restart"
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/libe/libevent/libevent-2.0-5_2.0.21-stable-1ubuntu1.14.04.1_amd64.deb Could not resolve 'archive.ubuntu.com'
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/m/memcached/memcached_1.4.14-0ubuntu9_amd64.deb Could not resolve 'archive.ubuntu.com'
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/libe/libevent/libevent-2.0-5_2.0.21-stable-1ubuntu1.14.04.1_amd64.deb Could not resolve 'archive.ubuntu.com'
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/m/memcached/memcached_1.4.14-0ubuntu9_amd64.deb Could not resolve 'archive.ubuntu.com'
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
Sunday, June 14, 2015
Docker container cannot access mounted volumes in OSX host
If you are running Nginx or Apache in your docker images while using those to write files (ex. cache) on the host machine, chances are you will get a permission error.
Bash into your container:
> docker-compose run bash
cd into the location that has your mounted volume and do a "ls -l", you may see the following:
drwxr-xr-x 1 1000 staff 646 Jun 15 03:39 app
In Nginx or Apache, the user is usually www-data. We need to associate www-data with the UID 1000.
In your Dockerfile, add the following:
> RUN usermod -u 1000 www-data
Now if you check the permission again, you would see the correct user.
drwxr-xr-x 1 www-data staff 646 Jun 15 03:39 app
Bash into your container:
> docker-compose run
cd into the location that has your mounted volume and do a "ls -l", you may see the following:
drwxr-xr-x 1 1000 staff 646 Jun 15 03:39 app
In Nginx or Apache, the user is usually www-data. We need to associate www-data with the UID 1000.
In your Dockerfile, add the following:
> RUN usermod -u 1000 www-data
Now if you check the permission again, you would see the correct user.
drwxr-xr-x 1 www-data staff 646 Jun 15 03:39 app
Saturday, June 13, 2015
Create your own Docker Registry with S3
The purpose of this post is to be able to deploy your own custom image to ElasticBeanstalk using docker registry through storing the images on Amazon S3.
Let's begin by cloning Docker Registry 2.0.
git clone https://github.com/docker/distribution.git
Generate self-signed certificates.
cd distribution
mkdir certs
openssl req \
-newkey rsa:2048 -nodes -keyout certs/domain.key \
-x509 -days 365 -out certs/domain.crt
Add TLS to config.yml
Let's begin by cloning Docker Registry 2.0.
git clone https://github.com/docker/distribution.git
Generate self-signed certificates.
cd distribution
mkdir certs
openssl req \
-newkey rsa:2048 -nodes -keyout certs/domain.key \
-x509 -days 365 -out certs/domain.crt
Add TLS to config.yml
vi ./cmd/registry/config.yml
Add the tls block to the http section like the following:
http:
addr: :5000
secret: asecretforlocaldevelopment
debug:
addr: localhost:5001
tls:
certificate: /go/src/github.com/docker/distribution/certs/domain.crt
key: /go/src/github.com/docker/distribution/certs/domain.key
Remove filesystem settings and use AWS s3 as repository storage:
storage:
#filesystem:
# rootdirectory: /tmp/registry
s3:
accesskey: awsaccesskey
secretkey: awssecretkey
region: us-west-1
bucket: bucketname
encrypt: true
secure: true
v4auth: true
chunksize: 5242880
rootdirectory: /s3/object/name/prefix
Settings: http://docs.docker.com/registry/configuration/#storage
Save this.
Build the image with a name (ex. docker_registry)
> docker build -t docker_registry .
Tag it. Note that I am using boot2docker on MacOSX. You can get your IP address by running "boot2docker ip".
> docker tag docker_registry:latest 192.168.59.103:5000/docker_registry:latest
Run the registry.
> docker run -p 5000:5000 docker_registry
If you try to push your an image, you will get a error saying you need to add an insecure registry.
> boot2docker ssh "echo $'EXTRA_ARGS=\"--insecure-registry 192.168.59.103:5000\"' | sudo tee -a /var/lib/boot2docker/profile && sudo /etc/init.d/docker restart"
Push an image:
> docker push 192.168.59.103:5000/{image}
#filesystem:
# rootdirectory: /tmp/registry
s3:
accesskey: awsaccesskey
secretkey: awssecretkey
region: us-west-1
bucket: bucketname
encrypt: true
secure: true
v4auth: true
chunksize: 5242880
rootdirectory: /s3/object/name/prefix
Settings: http://docs.docker.com/registry/configuration/#storage
Save this.
Build the image with a name (ex. docker_registry)
> docker build -t docker_registry .
Tag it. Note that I am using boot2docker on MacOSX. You can get your IP address by running "boot2docker ip".
> docker tag docker_registry:latest 192.168.59.103:5000/docker_registry:latest
Run the registry.
> docker run -p 5000:5000 docker_registry
If you try to push your an image, you will get a error saying you need to add an insecure registry.
> boot2docker ssh "echo $'EXTRA_ARGS=\"--insecure-registry 192.168.59.103:5000\"' | sudo tee -a /var/lib/boot2docker/profile && sudo /etc/init.d/docker restart"
Push an image:
> docker push 192.168.59.103:5000/{image}
Wednesday, June 3, 2015
boot2docker in terminal MacOSX
Initialize boot2docker
> boot2docker init
Start boot2docker
> boot2docker start
Set the environment variables in the current terminal.
> eval "$(boot2docker shellinit)"
Test run
> docker run hello-world
To run an Nginx server (-d for running in background):
> docker run -d -P --name web nginx
Stop
> boot2docker stop
Check status
> boot2docker status
Built an image:
> docker build -t .
Access home folder:
> cd $HOME
Mount a local directory to the image's directory
echo "my new site" > index.html
> docker run -d -P -v $HOME/site:/usr/share/nginx/html --name mysite nginx
upgrade boot2docker
> boot2docker stop
> boot2docker upgrade
> boot2docker init
Start boot2docker
> boot2docker start
Set the environment variables in the current terminal.
> eval "$(boot2docker shellinit)"
Test run
> docker run hello-world
To run an Nginx server (-d for running in background):
> docker run -d -P --name web nginx
Stop
> boot2docker stop
Check status
> boot2docker status
Built an image:
> docker build -t
Access home folder:
> cd $HOME
Mount a local directory to the image's directory
echo "my new site" > index.html
> docker run -d -P -v $HOME/site:/usr/share/nginx/html --name mysite nginx
upgrade boot2docker
> boot2docker stop
> boot2docker upgrade
Subscribe to:
Posts (Atom)