text stringlengths 0 93.6k |
|---|
shutit.send('pwd',note='We start in the root folder here too.') |
shutit.send('ls',note='The file "myfile" is not here.') |
shutit.logout(note='log out of the bash shell - type exit') |
shutit.login(command='docker exec -ti centos_container_1 /bin/bash',note='Log onto container 1 again') |
shutit.send('ls',note='The file "myfile" is still there in the first container.') |
shutit.logout(note='log out of the bash shell - type exit') |
# DOCKER IMAGES |
shutit.send('docker images',note='We can list the images we have on this _host_. We have one image (the centos one) which is the source of all our containers.') |
shutit.send('docker ps',note='But we have 100 containers.') |
# DOCKER COMMIT / HISTORY / LAYERS |
shutit.send('docker history centos',note='Containers are composed of _layers_. Each one represents a set of file changes analagous (but not the same as) a git commit. This is the history of the "centos" image layers.') |
shutit.send('docker commit centos_container_1 docker_101_image',note='To create a new image with myfile in, commit the container.') |
shutit.send('docker ps -q -a | xargs -n 1 docker rm -f 2>&1 > /dev/null &') |
shutit.send('docker images',note='That image is now listed alongside the centos one on our host.') |
shutit.send('docker history centos',note='Show the centos history.') |
shutit.send('docker history docker_101_image',note='Show the docker_101_image history. It is the same as the centos image with our extra layer.') |
# DOCKER LOGIN |
shutit.pause_point('Now log in to docker with "docker login" please.') |
docker_username = shutit.get_input('Please input your dockerhub username: ') |
shutit.send('docker tag docker_101_image ' + docker_username + '/docker_101_image',note='Re-tag the image with your docker username-space.') |
shutit.send('docker images',note='It is listed as a separate image with the same ID.') |
shutit.send('docker push ' + docker_username + '/docker_101_image',note='It is listed as a separate image with the same ID.') |
# PULL |
shutit.send('docker rmi ' + docker_username + '/docker_101_image',note='Delete our newly-created image.') |
shutit.send('docker rmi docker_101_image',note='Delete the previously-created identical image also.') |
shutit.send('docker images',note='Neither image is now available. Only the centos image remains, which we keep to avoid re-downloading.') |
shutit.send('docker pull ' + docker_username + '/docker_101_image',note='Pull the image back down. Notice it is a lot faster as only the extra layer we created is required.') |
shutit.login('docker run -ti ' + docker_username + '/docker_101_image /bin/bash',note='Run up bash in a new container from that image.') |
shutit.send('pwd',note='I am in the root folder again') |
shutit.send('ls',note='And the file we create earlier is there') |
shutit.logout(note='exit the container') |
shutit.send('docker ps -a -q | xargs docker rm -f') |
shutit.send('docker rmi ' + docker_username + '/docker_101_image',note='Remove the image we just pulled.') |
# DOCKERFILE |
shutit.send('mkdir -p docker_build && cd docker_build',note='Create a folder for our build.') |
shutit.send('''cat > Dockerfile << END |
FROM centos |
RUN touch /root/myfile |
CMD ['/bin/bash'] |
END''') |
shutit.send('cat Dockerfile',note='Cat the Dockerfile created for you. This Dockerfile that does the same action as before.') |
docker_image_name = shutit.get_input('Please input a new image name.') |
shutit.send('docker build -t ' + docker_username + '/' + docker_image_name + ' .',note='Build the docker image using the Dockerfile (rather than running and committing), and tag it with a new image name') |
shutit.send('docker push ' + docker_username + '/' + docker_image_name,note='Push the image to the dockerhub') |
shutit.send('docker rmi ' + docker_username + '/' + docker_image_name,note='Remove the image from our local machine') |
shutit.send('docker images',note='It is no longer available. Only the centos image remains.') |
shutit.send('rm -rf Dockerfile',note='Remove the Dockerfile we created') |
# DOCKERFILE FROM THAT BASE |
shutit.send('''cat > Dockerfile << END |
FROM ''' + docker_username + '/' + docker_image_name + ''' |
RUN touch /root/myfile2 |
CMD ['/bin/bash'] |
END''') |
shutit.send('cat Dockerfile',note='Dockerfile created for you that builds on the last one (rather than centos).') |
shutit.send('docker build -t newimage .',note='Build this new image from the new Dockerfile.') |
shutit.login('docker run -ti newimage /bin/bash',note='Run the newly-create image.') |
shutit.send('ls',note='The file myfile2 (from our new layer) and myfile (from our old image) is there.') |
shutit.logout(note='Log out of the new container - type exit') |
shutit.send('docker ps -a -q | xargs docker rm -f') |
shutit.send('docker rmi newimage',note='Destroy this new image') |
shutit.logout() |
shutit.logout() |
return True |
def get_config(self, shutit): |
# CONFIGURATION |
# shutit.get_config(module_id,option,default=None,boolean=False) |
# - Get configuration value, boolean indicates whether the item is |
# a boolean type, eg get the config with: |
# shutit.get_config(self.module_id, 'myconfig', default='a value') |
# and reference in your code with: |
# shutit.cfg[self.module_id]['myconfig'] |
shutit.get_config(self.module_id,'vagrant_image',default='ubuntu/trusty64') |
shutit.get_config(self.module_id,'vagrant_provider',default='virtualbox') |
return True |
def module(): |
return docker_101_tutorial( |
'tk.shutit.docker_101_tutorial', 1845506479.0001123, |
description='', |
maintainer='', |
delivery_methods=['bash'], |
depends=['shutit.tk.setup','shutit-library.virtualbox.virtualbox.virtualbox','tk.shutit.vagrant.vagrant.vagrant'] |
) |
# <FILESEP> |
""" |
Some key layers used for constructing a Capsule Network. These layers can used to construct CapsNet on other dataset, |
not just on MNIST. |
Author: Xifeng Guo, E-mail: `guoxifeng1990@163.com`, Github: `https://github.com/XifengGuo/CapsNet-Pytorch` |
""" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.